原创 【LintCode】打劫房屋

打劫房屋   描述 筆記  數據  評測 假設你是一個專業的竊賊,準備沿着一條街打劫房屋。每個房子都存放着特定金額的錢。你面臨的唯一約束條件是:相鄰的房子裝着相互聯繫的防盜系統,且 當相鄰的兩個房子同一天被打劫時,該系

原创 Redis開發最佳實踐

緩存在我們日常開發中佔據着舉足輕重的地位,通過緩存組件可以讓我們的系統有着多方位的提升空間。而Redis就一個代表性的緩存組件。正巧最近使用Redis比較頻繁,所以打算通過文章記錄一下在Redis開發中遇到的問題和一些開發規範 原

原创 【LeetCode】3. Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", t

原创 【LeetCode】24. Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should ret

原创 【LeetCode】48. Rotate Image

You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Coul

原创 【LeetCode】16. 3Sum Closest

Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Ret

原创 【LintCode】最大子數組

最大子數組   描述 筆記  數據  評測 給定一個整數數組,找到一個具有最大和的子數組,返回其最大和。  注意事項 子數組最少包含一個數 樣例 給出數組[−2,2,−3,4,−1,2,1,−5

原创 【LintCode】刪除排序數組中的重複數字

刪除排序數組中的重複數字  描述: 給定一個排序數組,在原數組中刪除重複出現的數字,使得每個元素只出現一次,並且返回新的數組的長度。 不要使用額外的數組空間,必須在原地沒有額外空間的條件下完成。 樣例 給出數組

原创 【LintCode】合併排序數組 II

合併兩個排序的整數數組A和B變成一個新的數組。  注意事項 你可以假設A具有足夠的空間(A數組的大小大於或等於m+n)去添加B中的元素 樣例 給出 A = [1, 2, 3, empty, empty], B =

原创 【LintCode】買賣股票的最佳時機

假設有一個數組,它的第i個元素是一支給定的股票在第i天的價格。如果你最多隻允許完成一次交易(例如,一次買賣股票),設計一個算法來找出最大利潤。 樣例 給出一個數組樣例 [3,2,3,1,2], 返回 1  思路:

原创 【LeetCode】4. Median of Two Sorted Arrays

There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays.