Leetcode详细解答
int32位
posted @
Mar 22, 2016 04:05:55 PM
in
algorithm
, 1801 阅读
转载请注明:
http://krystism.is-programmer.com/ 若有错误,请多多指正,谢谢!
最新代码:https://github.com/krystism/leetcode
Algorithms
1 Two Sum
2 Add Two Numbers
3 Longest Substring Without Repeating Characters(DP)
4 Median of Two Sorted Arrays(二分查找,有序数组求第k大的数)
7 Reverse Integer(溢出检测)
8 String to Integer (atoi)(溢出检测)
9 Palindrome Number
10 Regular Expression Matching(递归)
11 Container With Most Water
12 Integer to Roman(整数转罗马数,静态表)
13 Roman to Integer(罗马转整数,静态表)
14 Longest Common Prefix
15 3Sum
17 Letter Combinations of a Phone Number
18 4Sum
19 Remove Nth Node From End of List(先后指针)
20 Valid Parentheses(栈)
21 Merge Two Sorted Lists(归并)
22 Generate Parentheses(递归、搜索)
23 Merge k Sorted Lists(堆)
24 Swap Nodes in Pairs(链表操作)
25 Reverse Nodes in k-Group(链表操作)
26 Remove Duplicates from Sorted Array
27 Remove Element
28 Implement strStr()(KMP)
29 Divide Two Integers(位运算、最小负数绝对值、溢出检测)
31 Next Permutation(全排列)
33 Search in Rotated Sorted Array(二分搜索)
34 Search for a Range(二分)
35 Search Insert Position(二分查找)
36 Valid Sudoku(数独、hash表)
38 Count and Say(字符串和数字转化详解)
43 Multiply Strings(大数乘法)
46 Permutations(全排列)
47 Permutations II(全排列)
49 Anagrams(字符串,回文构词)
50 Pow(x, n)(二分,浮点数比较,INT_MIN绝对值)
53 Maximum Subarray(DP, 最大连续之和)
58 Length of Last Word
60 Permutation Sequence(康托展开)
64 Minimum Path Sum(DP,空间压缩)
65 Valid Number(细节题,状态机)
66 Plus One
67 Add Binary
69 Sqrt(x)(二分法,位运算)
72 Edit Distance(DP)
74 Search a 2D Matrix(二分搜索扩展(二维))
75 Sort Colors(O(1)空间,O(n)排序)
78 Subsets(递归、回溯、DFS)
79 Word Search(DFS、回溯)
82 Remove Duplicates from Sorted List II(链表操作
83 Remove Duplicates from Sorted List(链表操作)
86 Partition List(链表操作,类似于插入排序)
88 Merge Sorted Array(归并数组)
89 Gray Code(格雷码)
90 Subsets II(迭代)
92 Reverse Linked List II(链表逆转)
94 Binary Tree Inorder Traversal(中序遍历,迭代法)
96 Unique Binary Search Trees(迭代)
97 Interleaving String(DP)
98 Validate Binary Search Tree(BST, 中序遍历)
100 Same Tree(相同树,遍历)
101 Symmetric Tree(对称树)
102 Binary Tree Level Order Traversal(层次遍历)
104 Maximum Depth of Binary Tree(树深度)
107 Binary Tree Level Order Traversal II(层次遍历)
110 Balanced Binary Tree(平衡树)
111 Minimum Depth of Binary Tree
112 Path Sum(前序遍历)
113 Path Sum II(前序遍历)
114 Flatten Binary Tree to Linked List(后序遍历)
116 Populating Next Right Pointers in Each Node(层次遍历)
117 Populating Next Right Pointers in Each Node II(层次遍历,O(1)空间,指针操作
118 Pascal's Triangle(杨辉三角)
119 Pascal's Triangle II(杨辉三角第k行,求最大公约数
120 Triangle(DP,空间压缩)
121 Best Time to Buy and Sell Stock(最大数对之差,DP
122 Best Time to Buy and Sell Stock II(贪心算法)
123 Best Time to Buy and Sell Stock III(动态规划)
125 Valid Palindrome
128 Longest Consecutive Sequence
129 Sum Root to Leaf Numbers(前序遍历)
136 Single Number(位运算)
138 Copy List with Random Pointer(链表扩展,随机链表拷贝)
139 Word Break(DP,记忆搜索)
141 Linked List Cycle(快慢指针法)
142 Linked List Cycle II
143 Reorder List(链表操作,指针中间节点,逆转链表)
144 Binary Tree Preorder Traversal(迭代法前序遍历
145 Binary Tree Postorder Traversal(后序遍历)
146 LRU Cache(空间换时间)
147 Insertion Sort List(链表操作,插入排序)
148 Sort List(归并排序)
150 Evaluate Reverse Polish Notation(栈的应用)
151 Reverse Words in a String
152 Maximum Product Subarray(DP,最大连续之积)
153 Find Minimum in Rotated Sorted Array(二分)
154 Find Minimum in Rotated Sorted Array II(二分)
155 Min Stack(数据结构设计、栈的使用)
160 Intersection of Two Linked Lists
162 Find Peak Element(二分)
165 Compare Version Numbers
168 Excel Sheet Column Title(进制转化)
169 Majority Element
171 Excel Sheet Column Number(进制转化)
172 Factorial Trailing Zeroes
179 Largest Number(排序)
189 Rotate Array
190 Reverse Bits
191 Number of 1 Bits(位运算)
198 House Robber(DP)
199 Binary Tree Right Side View(层次遍历)
200 Number of Islands(递归标记、搜索)
201 Bitwise AND of Numbers Range(位运算)
202 Happy Number(环判断,模拟)
203 Remove Linked List Elements(链表操作)
204 Count Primes(素数,埃拉托斯特尼筛法)
205 Isomorphic Strings
206 Reverse Linked List(链表转置,递归&迭代)
207 Course Schedule(拓扑排序、图是否存在环、BFS、DFS)
208 Implement Trie (Trie树、字典树、前缀树)
210 Course Schedule II(拓扑排序)
211 Add and Search Word - Data structure design(Trie树)
213 House Robber II(DP)
215 Kth Largest Element in an Array(快排partition函数)
217 Contains Duplicate(hashset)
219 Contains Duplicate II(hashmap)
226 Invert Binary Tree(递归,树)
228 Summary Ranges
230 Kth Smallest Element in a BST(BST、中序遍历)
231 Power of Two(位运算,二进制1的个数)
232 Implement Queue using Stacks(栈模拟队列)
234 Palindrome Linked List(链表逆转、回文链表)
235 Lowest Common Ancestor of a Binary Search Tree(LCA, 最低公共祖先,二叉搜索树)
236 Lowest Common Ancestor of a Binary Tree(LCA,最低公共祖先,二叉树
237 Delete Node in a Linked List(O(1)删除单链表节点)
238 Product of Array Except Self(数组操作)
242 Valid Anagram(hash表,判断两个字符串出现的字符和次数均相同)
337 House Robber III(DFS,递归)
338 Counting Bits(二进制1的个数,迭代法)
Database
Shell
转载请注明:
http://krystism.is-programmer.com/ 若有错误,请多多指正,谢谢!
2020年2月24日 16:07
According to size from your space and may be items within just, cleaning normally requires hours, time or one month. Let much of our cleaning small business in Dubai, UAE offer hand. We could actually help help your house be, business and workplace wash again. Let usa do their work so you have got more period to do furthermore important for everyone, whether it will be spending precious time with your dependents, working ınside your office or in operation.