原创 vetor, list, map, set的區別
List封裝了鏈表,Vector封裝了數組, list和vector得最主要的區別在於vector使用連續內存存儲的,他支持[]運算符,而list是以鏈表形式實現的,不支持[]。 Vector對於隨機訪問的速度很快,但是對於插入
原创 【leetcode】Count and Say
Count and Say The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221
原创 【leetcode】House Robber II
House Robber II Note: This is an extension of House Robber. After robbing those houses on that street, the thief h
原创 【leetcode】Subsets 1&2
Subsets Given a set of distinct integers, nums, return all possible subsets. Note: • Elements in a subset must
原创 【leetcode】Jump Game II
Jump Game II Given an array of non-negative integers, you are initially positioned at the first index of the array.
原创 【leetcode】Sqrt(x)
Sqrt(x) Implement int sqrt(int x). Compute and return the square root of x. 思路: 如果不知道二分之後左右的取法的話,可以找個實例進行推測。 cla
原创 【leetcode】Unique Paths II
Unique Paths II Follow up for “Unique Paths”: Now consider if some obstacles are added to the grids. How many un
原创 【leetcode】Longest Consecutive Sequence
Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest consecutive elemen
原创 【leetcode】Reverse Linked List II
Reverse Linked List II Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: G
原创 【leetcode】Combination Sum
Combination Sum Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C whe
原创 【leetcode】Combination Sum II
Combination Sum II Given a collection of candidate numbers (C) and a target number (T), find all unique combination
原创 【leetcode】Pow(x, n)
Pow(x, n) Implement pow(x, n). 思路: 思路就是遞歸,用簡單遞歸的方法是O(n)的複雜度,但是如果二分之後再遞歸,複雜度爲O(lg(n))。但是一定注意leetcode有個極限值-21474836
原创 【leetcode】Path Sum II
Path Sum II Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.
原创 【leetcode】Multiply Strings
Multiply Strings Given two numbers represented as strings, return multiplication of the numbers as a string. Note:
原创 【leetcode】Contains Duplicate
Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your function should retu