LeetCode LintCode 干货全集 2018

Java Algorithm Problems

序言

从开始这个Github已经有将近三四年时间, 很高兴可以帮到有需要的人. 我一直认为, 知识本身是无价的, 因此每逢闲暇, 我就会来维护, 给刷题的朋友们一些我的想法和见解.

希望大家学习顺利, 对未来充满希望. 有问题可以给我写邮件(wangdeve@gmail.com), 或者在GitHub上发issue给我.

转眼已经2018年, 我过去写过的两版文章已经算是过期, 因为过去的题目总共只有大约300多道, 而现在LeetCode有了800多, 而LintCode竟然出现了超一千. 我自己所涵盖的总结, 将近500道题目, 全部在下面的这张表格里 (题号与leetcode不对应, 只是表格编号而已)

可想而知, 刷爆所有题目已经是不可能, 而大家也更应该对自己有更清楚地认识, 有侧重点, 分知识点地去刷题. 在这篇文章之后, 我会陆续把我自己的其他总结分类, 用文章的方式, 一份份地贴出来, 供大家参考.

如果有什么不同的见解, 欢迎在文章下面留言, 或者邮件与我交流. 能够帮到你的地方, 一定尽力而为. 中国人在国外, 一定要互相拉一把.

下面进入干货索引.

SquenceProblemLevelLanguageTagsVideo Tutorial
0Count of Smaller Number before itself.javaHardJava[]
1Evaluate Division.javaMediumJava[BFS, DFS, Graph, Union Find]
2Fraction to Recurring Decimal.javaMediumJava[Hash Table, Math]
3Gray Code.javaMediumJava[Backtracking]
4Hamming Distance.javaEasyJava[]
5Happy Number.javaEasyJava[]
6HashWithArray.javaEasyJava[]
7Heaters.javaEasyJava[]
8IndexMatch.javaEasyJava[]
9Insert Node in a Binary Search Tree .javaEasyJava[BST]
10Jewels and Stones.javaEasyJava[Hash Table]
11Kth Smallest Sum In Two Sorted Arrays.javaHardJava[]
12LFU Cache.javaHardJava[Design, Hash Table]
13Longest Univalue Path.javaEasyJava[]
14Majority Number II.javaMediumJava[Enumeration, Greedy]
15Majority Number III.javaMediumJava[Hash Table, Linked List]
16Matrix Zigzag Traversal.javaEasyJava[]
17Maximum Subarray III.javaReviewJava[]
18Minimum Absolute Difference in BST.javaEasyJava[BST]
19Minimum Height Trees.javaMediumJava[BFS, Graph]
20Missing Ranges.javaMediumJava[Array]
21Next Permutation.javaMediumJava[Array]
22O(1) Check Power of 2.javaEasyJava[Bit Manipulation]
23Palindrome Permutation II.javaMediumJava[Backtracking, Permutation]
24Partition Array by Odd and Even.javaEasyJava[Array, Two Pointers]
25Pascal’s Triangle II.javaEasyJava[]
26Permutation Index.javaEasyJava[]
27Permutation Sequence.javaMediumJava[Backtracking, Math]
28Prefix and Suffix Search.javaHardJava[Trie]
29Product of Array Exclude Itself.javaMediumJava[Array]
30Recover Rotated Sorted Array.javaEasyJava[Array]
31Remove Duplicates from Unsorted List.javaMediumJava[Linked List]
32Remove Node in Binary Search Tree.javaHardJava[BST]
33Reshape the Matrix.javaEasyJava[]
34Reverse String.javaEasyJava[]
35Rotate Image.javaMediumJava[Array, Enumeration]
36Search in Rotated Sorted Array II.javaMediumJava[Array, Binary Search]
37Search Insert Position.javaEasyJava[]
38Shortest Word Distance.javaEasyJava[]
39Single Number II.javaMediumJava[Bit Manipulation]
40Single Number III.javaMediumJava[Bit Manipulation]
41Single Number.javaEasyJava[]
42Space Replacement.javaMediumJava[String]
43Stone Game.javaMediumJava[DP]
44String Permutation.javaEasyJava[]
45Subarray Sum II.javaHardJava[Array, Binary Search, Two Pointers]
46The Smallest Difference.javaMediumJava[Array, Sort, Two Pointers]
47Total Occurrence of Target.javaMediumJava[]
48Trailing Zeros.javaEasyJava[Math]
49Two Lists Sum.javaMediumJava[Linked List]
50Two Strings Are Anagrams.javaEasyJava[]
51Valid Sudoku.javaEasyJava[Enumeration, Hash Table]
52Word Pattern.javaEasyJava[]
53Zigzag Iterator.javaMediumJava[BST]
54Find Anagram Mappings.javaEasyJava[Hash Table]
55Judge Route Circle.javaEasyJava[String]
56Island Perimeter.javaEasyJava[Hash Table]
57Power of Three.javaEasyJava[Math]
58Plus One.javaEasyJava[Array, Math]
59Power of Two.javaEasyJava[Bit Manipulation, Math]
60Reverse Vowels of a String.javaEasyJava[String, Two Pointers]
61Guess Number Higher or Lower.javaEasyJava[Binary Search]
62Encode and Decode TinyURL.javaMediumJava[Hash Table, Math]
63Wiggle Sort.javaMediumJava[Array, Sort]
64Queue Reconstruction by Height.javaMediumJava[Greedy]
65Two Sum II – Input array is sorted.javaMediumJava[Array, Binary Search, Two Pointers]
662 Sum II.javaMediumJava[Array, Binary Search, Two Pointers]
67Coin Change.javaMediumJava[Backpack DP, DP, Memoization]
68Maximum Product Subarray.javaMediumJava[Array, DP, Subarray]
693 Sum Closest.javaMediumJava[Array, Two Pointers]
70Triangle Count.javaMediumJava[Array]
713Sum.javaMediumJava[Array, Two Pointers]
72k Sum.javaHardJava[DP]
73Unique Binary Search Tree.javaMediumJava[BST, DP, Tree]
74Trim a Binary Search Tree.javaEasyJava[BST, Tree]
75Unique Paths II.javaMediumJava[Array, Coordinate DP, DP]
76Bomb Enemy.javaMediumJava[Coordinate DP, DP]
773Sum Smaller.javaMediumJava[Array, Two Pointers]
78Array Partition I.javaEasyJava[Array]
791-bit and 2-bit Characters.javaEasyJava[Array]
80Non-decreasing Array.javaEasyJava[Array]
81Max Consecutive Ones.javaEasyJava[Array]
82Find All Numbers Disappeared in an Array.javaEasyJava[Array]
83Maximum Average Subarray I.javaEasyJava[Array, Subarray]
84Largest Number At Least Twice of Others.javaEasyJava[Array]
85Toeplitz Matrix.javaEasyJava[Array]
86Sum of Two Integers.javaEasyJava[Bit Manipulation]
87Swap Bits.javaEasyJava[Bit Manipulation]
88Update Bits.javaMediumJava[Bit Manipulation]
89Maximum XOR of Two Numbers in an Array.javaMediumJava[Bit Manipulation, Trie]
90Perfect Squares.javaMediumJava[BFS, DP, Math, Partition DP]
91Backpack VI.javaMediumJava[Backpack DP, DP]
92Copy Books.javaHardJava[Binary Search, DP, Partition DP]
93Valid Perfect Square.javaReviewJava[Binary Search, Math]
94Intersection of Two Arrays II.javaEasyJava[Binary Search, Hash Table, Sort, Two Pointers]
95Scramble String.javaHardJava[DP, Interval DP, String]
96Binary Search Tree Iterator.javaMediumJava[BST, Design, Stack, Tree]
97Flatten Nested List Iterator.javaMediumJava[Design, Stack]
98Best Time to Buy and Sell Stock with Cooldown.javaMediumJava[DP]
99Find Peak Element.javaMediumJava[Array, Binary Search]
100Longest Common Subsequence.javaMediumJava[DP, Double Sequence DP, Sequence DP]
101Interleaving String.javaHardJava[DP, String]
102Letter Combinations of a Phone Number.javaMediumJava[Backtracking, String]
103Edit Distance.javaHardJava[DP, Double Sequence DP, Sequence DP, String]
104Distinct Subsequences.javaHardJava[DP, String]
105Majority Element.javaEasyJava[Array, Bit Manipulation, Divide and Conquer]
106Ones and Zeroes.javaHardJava[DP]
107Pow(x, n).javaMediumJava[Binary Search, Math]
108Word Break II.javaHardJava[Backtracking, DFS, DP, Hash Table, Memoization]
109Nested List Weight Sum.javaEasyJava[BFS, DFS]
110Same Tree.javaEasyJava[DFS, Tree]
111Convert Sorted Array to Binary Search Tree.javaEasyJava[DFS, Divide and Conquer, Tree]
112Construct Binary Tree from Preorder and Inorder Traversal.javaMediumJava[Array, DFS, Divide and Conquer, Hash Table, Tree]
113Add Digits.javaEasyJava[Math]
114Add Two Numbers.javaMediumJava[Linked List, Math]
115Add Two Numbers II.javaMediumJava[Linked List]
116Balanced Binary Tree.javaMediumJava[DFS, Tree]
117Valid Anagram.javaEasyJava[Hash Table, Sort]
118Populating Next Right Pointers in Each Node.javaMediumJava[DFS, Divide and Conquer, Tree]
119Validate Binary Search Tree.javaMediumJava[BST, DFS, Divide and Conquer, Tree]
120Convert Sorted List to Binary Search Tree.javaMediumJava[BST, DFS, Divide and Conquer, Linked List]
121Flatten Binary Tree to Linked List.javaMediumJava[Binary Tree, DFS]
122Binary Tree Paths.javaEasyJava[Backtracking, Binary Tree, DFS]
123Minimum Size Subarray Sum.javaMediumJava[Array, Binary Search, Subarray, Two Pointers]
124Longest Substring Without Repeating Characters.javaMediumJava[Hash Table, String, Two Pointers]
125Minimum Window Substring.javaHardJava[Hash Table, String, Two Pointers]
126Linked List Cycle.javaEasyJava[Linked List, Two Pointers]
127Remove Nth Node From End of List.javaMediumJava[Linked List, Two Pointers]
128Longest Substring with At Most K Distinct Characters.javaHardJava[Hash Table, Sliding Window, String]
129Linked List Cycle II.javaMediumJava[Linked List, Math, Two Pointers]
130Kth Smallest Element in a Sorted Matrix.javaMediumJava[Binary Search, Heap]
131Find Minimum in Rotated Sorted Array.javaMediumJava[Array, Binary Search]
132Find Minimum in Rotated Sorted Array II.javaHardJava[Array, Binary Search]
133Connecting Graph.javaMediumJava[Union Find]
134Connecting Graph II.javaMediumJava[Union Find]
135Connecting Graph III.javaMediumJava[Union Find]
136Number of Islands.javaMediumJava[BFS, DFS, Matrix DFS, Union Find]
137Number of Islands II.javaHardJava[Union Find]
138Surrounded Regions.javaMediumJava[BFS, DFS, Matrix DFS, Union Find]
139Implement Trie (Prefix Tree).javaMediumJava[Design, Trie]
140Add and Search Word – Data structure design.javaMediumJava[Backtracking, Design, Trie]
141Word Search II.javaHardJava[Backtracking, DFS, Trie]
142Word Search.javaMediumJava[Array, Backtracking, DFS]
143Word Squares.javaHardJava[Backtracking, Trie]
144Trapping Rain Water.javaHardJava[Array, Stack, Two Pointers]
145Min Stack.javaEasyJava[Design, Stack]
146Implement Queue using Stacks.javaEasyJava[Design, Stack]
147Decode String.javaMediumJava[DFS, Divide and Conquer, Stack]
148Largest Rectangle in Histogram.javaHardJava[Array, Monotonous Stack, Stack]
149Maximum Binary Tree.javaMediumJava[Stack, Tree]
150Reverse Integer.javaEasyJava[Math]
151Swap Nodes in Pairs.javaMediumJava[Linked List]
152Find Peak Element II.javaHardJava[Binary Search, DFS, Divide and Conquer]
153Sqrt(x).javaEasyJava[Binary Search, Math]
154First Bad Version.javaEasyJava[Binary Search]
155Wood Cut.javaMediumJava[Binary Search]
156Find the Duplicate Number.javaMediumJava[Array, Binary Search, Two Pointers]
157Palindrome Pairs.javaHardJava[Hash Table, String, Trie]
158Game of Life.javaMediumJava[Array]
159Maximum Average Subarray II.javaReviewJava[Array, Binary Search, PreSum]
160Meeting Rooms.javaEasyJava[PriorityQueue, Sort, Sweep Line]
161Number of Airplane in the sky.javaMediumJava[Array, Interval, PriorityQueue, Sort, Sweep Line]
162Meeting Rooms II.javaMediumJava[Greedy, Heap, PriorityQueue, Sort, Sweep Line]
163The Skyline Problem.javaReviewJava[Binary Indexed Tree, Divide and Conquer, Heap, PriorityQueue, Segment Tree, Sweep Line]
164Unique Path.javaMediumJava[Array, Coordinate DP, DP]
165Maximal Rectangle.javaHardJava[Array, DP, Hash Table, Stack]
166Maximal Square.javaMediumJava[Coordinate DP, DP]
167Longest Increasing Path in a Matrix.javaHardJava[Coordinate DP, DFS, DP, Memoization, Topological Sort]
168Coins in a Line.javaMediumJava[DP, Game Theory, Greedy]
169Coins in a Line II.javaMediumJava[Array, DP, Game Theory, Memoization, MiniMax]
170Binary Tree Inorder Traversal.javaEasyJava[Hash Table, Stack, Tree]
171Binary Tree Postorder Traversal.javaMediumJava[Stack, Tree, Two Stacks]
172Change to Anagram.javaEasyJava[String]
173Classical Binary Search.javaEasyJava[Binary Search]
174Climbing Stairs.javaEasyJava[DP, Memoization, Sequence DP]
175Coins in a Line III.javaHardJava[Array, DP, Game Theory, Interval DP, Memoization]
176Closest Binary Search Tree Value.javaEasyJava[BST, Binary Search, Tree]
177Compare Version Numbers.javaMediumJava[String]
178Count Complete Tree Nodes.javaMediumJava[Binary Search, Tree]
179Course Schedule.javaMediumJava[BFS, Backtracking, DFS, Graph, Topological Sort]
180Course Schedule II.javaMediumJava[BFS, DFS, Graph, Topological Sort]
181Binary Tree Preorder Traversal.javaEasyJava[BFS, DFS, Stack, Tree]
182Closest Number in Sorted Array.javaEasyJava[Binary Search]
183Complete Binary Tree.javaEasyJava[BFS, Tree]
184Compare Strings.javaEasyJava[String]
185Contains Duplicate.javaEasyJava[Array, Hash Table]
186Contains Duplicate II.javaEasyJava[Array, Hash Table]
187Contains Duplicate III.javaMediumJava[BST]
188Burst Balloons.javaHardJava[DP, Divide and Conquer, Interval DP, Memoization]
189Nim Game.javaEasyJava[Brainteaser, DP, Game Theory]
190Convert Integer A to Integer B.javaEasyJava[Bit Manipulation]
191Cosine Similarity.javaEasyJava[Basic Implementation]
192Count 1 in Binary.javaEasyJava[Bit Manipulation]
193Count and Say.javaEasyJava[Basic Implementation, String]
194K Edit Distance.javaHardJava[DP, Double Sequence DP, Sequence DP, Trie]
195Jump Game.javaMediumJava[Array, DP, Greedy]
196Coin Change 2.javaMediumJava[Backpack DP, DP]
197Paint House.javaEasyJava[DP, Sequence DP, Status DP]
198Decode Ways.javaMediumJava[DP, Partition DP, String]
199Longest Continuous Increasing Subsequence.javaEasyJava[Array, Coordinate DP, DP]
200Minimum Path Sum.javaMediumJava[Array, Coordinate DP, DP]
201Counting Bits.javaMediumJava[Bit Manipulation, Bitwise DP, DP]
202Continuous Subarray Sum.javaMediumJava[Coordinate DP, DP, Math, Subarray]
203House Robber.javaEasyJava[DP, Sequence DP]
204House Robber II.javaMediumJava[DP, Sequence DP, Status DP]
205House Robber III.javaMediumJava[DFS, DP, Status DP, Tree]
206Paint House II.javaHardJava[DP, Sequence DP, Status DP]
207Best Time to Buy and Sell Stock III.javaHardJava[Array, DP, Sequence DP]
208Best Time to Buy and Sell Stock IV.javaHardJava[DP, Sequence DP]
209Russian Doll Envelopes.javaHardJava[Binary Search, Coordinate DP, DP]
210Permutation in String.javaMediumJava[Two Pointers]
211Permutations II.javaMediumJava[Backtracking]
212Shuffle an Array.javaMediumJava[Permutation]
213Find All Anagrams in a String.javaEasyJava[Hash Table, Sliding Window]
214Group Anagrams.javaMediumJava[Hash Table, String]
215Backpack.javaMediumJava[Backpack DP, DP]
216Backpack II.javaMediumJava[Backpack DP, DP]
217Backpack V.javaMediumJava[Backpack DP, DP]
218Count Primes.javaEasyJava[Hash Table, Math]
219Delete Node in a Linked List.javaEasyJava[Linked List]
220Excel Sheet Column Number.javaEasyJava[Math]
221Excel Sheet Column Title.javaEasyJava[Math]
222Flip Game.javaEasyJava[String]
223Expression Tree Build.javaHardJava[Binary Tree, Expression Tree, Minimum Binary Tree, Stack]
224Expression Evaluation.javaHardJava[Binary Tree, DFS, Expression Tree, Minimum Binary Tree, Stack]
225Convert Expression to Polish Notation.javaHardJava[Binary Tree, DFS, Expression Tree, Stack]
226Convert Expression to Reverse Polish Notation.javaHardJava[Binary Tree, DFS, Expression Tree, Stack]
227Evaluate Reverse Polish Notation.javaMediumJava[Stack]
228Decode Ways II.javaHardJava[DP, Enumeration, Partition DP]
229Palindrome Partitioning II.javaHardJava[DP, Partition DP]
230Backpack III.javaHardJava[Backpack DP, DP]
231First Missing Positive.javaHardJava[Array]
232Implement strStr().javaEasyJava[String, Two Pointers]
233Insertion Sort List.javaMediumJava[Linked List, Sort]
234Interleaving Positive and Negative Numbers.javaMediumJava[Two Pointers]
235Largest Number.javaMediumJava[Sort]
236Last Position of Target.javaEasyJava[Binary Search]
237Length of Last Word.javaEasyJava[String]
238Longest Common Substring.javaMediumJava[DP, Double Sequence DP, Sequence DP, String]
239Longest Increasing Continuous subsequence.javaEasyJava[Array, Coordinate DP, DP]
240Longest Increasing Continuous subsequence II.javaMediumJava[Array, Coordinate DP, DP, Memoization]
241N-Queens.javaHardJava[Backtracking]
242N-Queens II.javaHardJava[Backtracking]
243Maximum Subarray.javaEasyJava[Array, DFS, DP, Divide and Conquer, PreSum, Sequence DP, Subarray]
244Maximum Subarray II.javaMediumJava[Array, DP, Greedy, PreSum, Sequence DP, Subarray]
245Median.javaEasyJava[Array, Quick Select, Quick Sort]
246Middle of Linked List.javaEasyJava[Linked List]
247Singleton.javaEasyJava[Design]
248Remove Linked List Elements.javaEasyJava[Linked List]
249Fibonacci.javaEasyJava[DP, Math, Memoization]
250Palindrome Linked List.javaEasyJava[Linked List, Two Pointers]
251Reverse Linked List.javaEasyJava[Linked List]
252Reverse Linked List II .javaMediumJava[Linked List]
253Intersection of Two Linked Lists.javaEasyJava[Linked List]
254Palindrome Permutation.javaEasyJava[Hash Table]
255Valid Palindrome.javaEasyJava[String, Two Pointers]
256Implement Stack using Queues.javaEasyJava[Design, Stack]
257Implement Stack.javaEasyJava[Stack]
258Invert Binary Tree.javaEasyJava[BFS, DFS, Tree]
259Maximum Depth of Binary Tree.javaEasyJava[DFS, Tree]
260Minimum Depth of Binary Tree.javaEasyJava[BFS, DFS, Tree]
261Symmetric Tree.javaEasyJava[BFS, DFS, Tree]
262Tweaked Identical Binary Tree.javaEasyJava[DFS, Tree]
263Merge Two Binary Trees.javaEasyJava[DFS, Tree]
264Subtree.javaEasyJava[DFS, Tree]
265Lowest Common Ancestor of a Binary Tree.javaMediumJava[DFS, Tree]
266Lowest Common Ancestor II.javaEasyJava[Hash Table, Tree]
267Lowest Common Ancestor of a Binary Search Tree.javaMediumJava[BST, DFS, Tree]
268Hash Function.javaEasyJava[Hash Table]
269Merge Two Sorted Lists.javaEasyJava[Linked List]
270Missing Number.javaEasyJava[Array, Bit Manipulation, Math]
271LRU Cache.javaHardJava[Design, Hash Table, Linked List]
272Remove Duplicates from Sorted Array.javaEasyJava[Array, Two Pointers]
273Remove Duplicates from Sorted Array II.javaMediumJava[Array, Two Pointers]
274Remove Duplicates from Sorted List.javaEasyJava[Linked List]
275Remove Duplicates from Sorted List II.javaMediumJava[Linked List]
276QuickSort.javaMediumJava[Quick Sort, Sort]
277MergeSort.javaMediumJava[Merge Sort, Sort]
278Longest Word in Dictionary.javaEasyJava[Hash Table, Trie]
279Binary Tree Level Order Traversal.javaMediumJava[BFS, DFS, Tree]
280Binary Tree Level Order Traversal II.javaMediumJava[BFS, Tree]
281Binary Tree Longest Consecutive Sequence II.javaMediumJava[DFS, Divide and Conquer, Double Recursive, Tree]
282Binary Tree Maximum Path Sum.javaHardJava[DFS, DP, Tree, Tree DP]
283Path Sum.javaEasyJava[DFS, Tree]
284Path Sum II.javaEasyJava[Backtracking, DFS, Tree]
285Path Sum III.javaEasyJava[DFS, Double Recursive, Tree]
286Rotate String.javaEasyJava[String]
287Combinations.javaMediumJava[Backtracking, Combination, DFS]
288Combination Sum IV.javaMediumJava[Array, Backpack DP, DP]
289Binary Tree Right Side View.javaMediumJava[BFS, DFS, Tree]
290Binary Tree Maximum Path Sum II.javaMediumJava[DFS, Tree]
291Rotate List.javaMediumJava[Linked List, Two Pointers]
292Basic Calculator.javaHardJava[Binary Tree, Expression Tree, Math, Minimum Binary Tree, Stack]
293Longest Consecutive Sequence.javaHardJava[Array, Hash Table, Union Find]
294Binary Tree Longest Consecutive Sequence.javaMediumJava[DFS, Divide and Conquer, Tree]
295Number of Connected Components in an Undirected Graph.javaMediumJava[BFS, DFS, Graph, Union Find]
296Next Closest Time.javaMediumJava[Basic Implementation, Enumeration, String]
297Serialize and Deserialize Binary Tree.javaHardJava[BFS, DFS, Deque, Design, Divide and Conquer, Tree]
298Partition Array.javaMediumJava[Array, Quick Sort, Sort, Two Pointers]
299Word Ladder.javaMediumJava[BFS]
300Unique Word Abbreviation.javaMediumJava[Design, Hash Table]
301Unique Binary Search Tree II.javaMediumJava[BST, DP, Divide and Conquer, Tree]
302Ugly Number.javaMediumJava[Math]
303Top K Frequent Words.javaMediumJava[Hash Table, Heap, MaxHeap, MinHeap, PriorityQueue, Trie]
304Segment Tree Build.javaMediumJava[Binary Tree, Divide and Conquer, Lint, Segment Tree]
305Segment Tree Build II.javaMediumJava[Binary Tree, Divide and Conquer, Lint, Segment Tree]
306Segment Tree Query.javaMediumJava[Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree]
307Segment Tree Modify.javaMediumJava[Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree]
308Segment Tree Query II.javaMediumJava[Binary Tree, DFS, Divide and Conquer, Lint, Segment Tree]
309Count of Smaller Numbers After Self.javaHardJava[BST, Binary Indexed Tree, Binary Search, Divide and Conquer, Segment Tree]
310ColorGrid.javaMediumJava[Design, Hash Table]
311Container With Most Water.javaMediumJava[Array, Two Pointers]
312Copy List with Random Pointer.javaMediumJava[Hash Table, Linked List]
313Encode and Decode Strings.javaMediumJava[String]
314Fast Power.javaMediumJava[DFS, Divide and Conquer]
315Find the Connected Component in the Undirected Graph.javaMediumJava[BFS, DFS]
316HashWithCustomizedClass(LinkedList).javaMediumJava[Hash Table]
317Interval Minimum Number.javaMediumJava[Binary Search, Divide and Conquer, Lint, Segment Tree]
318Interval Sum.javaMediumJava[Binary Search, Lint, Segment Tree]
319Kth Smallest Element in a BST.javaMediumJava[BST, DFS, Stack, Tree]
320Longest Common Prefix.javaEasyJava[String]
321Majority Element II.javaMediumJava[Array]
322Partition List.javaMediumJava[Linked List, Two Pointers]
323Peeking Iterator.javaMediumJava[Design]
324Rehashing.javaMediumJava[Hash Table]
325Reorder List.javaMediumJava[Linked List]
326Restore IP Addresses.javaMediumJava[Backtracking, DFS, String]
327Reverse Words in a String.javaMediumJava[String]
328Reverse Words in a String II.javaMediumJava[String]
329Reverse Words in a String III.javaEasyJava[String]
330Search a 2D Matrix.javaMediumJava[Array, Binary Search]
331Search a 2D Matrix II.javaMediumJava[Binary Search, Divide and Conquer]
332Search for a Range.javaMediumJava[Array, Binary Search]
333Search Range in Binary Search Tree .javaMediumJava[BST, Binary Tree]
334Merge Sorted Array II.javaEasyJava[Array]
335Nth to Last Node in List.javaEasyJava[Linked List]
336Sort List.javaMediumJava[Divide and Conquer, Linked List, Merge Sort, Sort]
337Summary Ranges.javaMediumJava[Array]
338Topological Sorting.javaMediumJava[BFS, DFS, Topological Sort]
339Remove Duplicate Letters.javaHardJava[Greedy, Hash Table, Stack]
340Spiral Matrix.javaMediumJava[Array, Enumeration]
341Expression Add Operators.javaHardJava[Backtracking, DFS, Divide and Conquer, String]
342Insert Interval.javaHardJava[Array, PriorityQueue, Sort]
343Shortest Palindrome.javaHardJava[KMP, String]
344Two Sum.javaEasyJava[Array, Hash Table]
345K Empty Slots.javaHardJava[Array, BST, TreeSet]
346Count of Range Sum.javaHardJava[BST, Divide and Conquer, Merge Sort, PreSum]
347Max Sum of Rectangle No Larger Than K.javaHardJava[Array, BST, Binary Search, DP, Queue, TreeSet]
348Perfect Rectangle.javaHardJava[Design, Geometry, Hash Table]
349Construct Binary Tree from Inorder and Postorder Traversal.javaMediumJava[Array, DFS, Divide and Conquer, Tree]
350Generate Parentheses.javaMediumJava[Backtracking, DFS, Sequence DFS, String]
351Strobogrammatic Number II.javaMediumJava[DFS, Enumeration, Math, Sequence DFS]
352Flip Game II.javaMediumJava[Backtracking, DFS, DP]
353Max Area of Island.javaEasyJava[Array, DFS]
354Max Points on a Line.javaHardJava[Array, Geometry, Hash Table, Math]
355Number of Digit One.javaHardJava[Math]
356Binary Representation.javaHardJava[Bit Manipulation, String]
357Palindrome Partitioning.javaMediumJava[Backtracking, DFS]
358Recover Binary Search Tree.javaHardJava[BST, DFS, Tree]
359Subarray Sum.javaEasyJava[Array, Hash Table, PreSum, Subarray]
360Submatrix Sum.javaMediumJava[Array, Hash Table, PreSum]
361Longest Palindromic Substring.javaMediumJava[DP, String]
362Longest Palindromic Subsequence.javaMediumJava[DFS, DP, Interval DP, Memoization]
363Jump Game II.javaHardJava[Array, Coordinate DP, DP, Greedy]
364Gas Station.javaMediumJava[Greedy]
365Triangles.javaMediumJava[Array, Coordinate DP, DFS, DP, Memoization]
366Range Sum Query – Immutable.javaEasyJava[DP, PreSum]
367Longest Valid Parentheses.javaHardJava[Coordinate DP, Stack, String]
368Remove Invalid Parentheses.javaReviewJava[BFS, DFS, DP]
369Merge Intervals.javaMediumJava[Array, PriorityQueue, Sort, Sweep Line]
370H-Index.javaMediumJava[Bucket Sort, Hash Table, Sort]
371H-Index II.javaMediumJava[Binary Search]
372Sort Colors.javaMediumJava[Array, Partition, Quick Sort, Sort, Two Pointers]
373Sort Colors II.javaMediumJava[Partition, Quick Sort, Sort, Two Pointers]
374Sort Letters by Case.javaMediumJava[Partition, Sort, String, Two Pointers]
375Subarray Sum Closest.javaMediumJava[PreSum, PriorityQueue, Sort, Subarray]
376Task Scheduler.javaMediumJava[Array, Enumeration, Greedy, PriorityQueue, Queue]
377Rearrange String k Distance Apart.javaHardJava[Greedy, Hash Table, Heap]
378Exam Room.javaMediumJava[PriorityQueue, Sort]
379Anagrams.javaMediumJava[Array, Hash Table]
380Path Sum IV.javaMediumJava[DFS, Hash Table, Tree]
381Longest Words.javaEasyJava[Hash Table, String]
382Unique Characters.javaEasyJava[Array, String]
383Number Of Corner Rectangles.javaMediumJava[DP, Math]
384Palindromic Substrings.javaMediumJava[DP, String]
385Multiply Strings.javaMediumJava[Math, String]
386Subsets.javaMediumJava[Array, BFS, Backtracking, Bit Manipulation, DFS]
387Subsets II.javaMediumJava[Array, BFS, Backtracking, DFS]
388Combination Sum.javaMediumJava[Array, Backtracking, Combination, DFS]
389Combination Sum II.javaMediumJava[Array, Backtracking, Combination, DFS]
390Combination Sum III.javaMediumJava[Array, Backtracking, Combination, DFS]
391Product of Array Except Self.javaMediumJava[Array, PreProduct]
392Total Hamming Distance.javaMediumJava[Bit Manipulation]
393Smallest Subtree with all the Deepest Nodes.javaMediumJava[DFS, Divide and Conquer, Tree]
394Binary Gap.javaEasyJava[Bit Manipulation]
395Subarray Sum Equals K.javaMediumJava[Array, Hash Table, PreSum, Subarray]
396Maximize Distance to Closest Person.javaEasyJava[Array]
397Simplify Path.javaMediumJava[Stack, String]
398Convert Binary Search Tree to Sorted Doubly Linked List (extra space).javaMediumJava[Linked List, Stack, Tree]
399Paint Fence.javaEasyJava[DP, Sequence DP]
400Binary Tree Zigzag Level Order Traversal.javaMediumJava[BFS, Stack, Tree]
401Word Break.javaMediumJava[DP, Hash Table, Sequence DP]
402Best Time to Buy and Sell Stock.javaEasyJava[Array, DP, Sequence DP]
403Best Time to Buy and Sell Stock II.javaEasyJava[Array, DP, Greedy, Sequence DP, Status DP]
404Longest Increasing Subsequence.javaMediumJava[Binary Search, Coordinate DP, DP, Memoization]
405Best Time to Buy and Sell Stock with Transaction Fee.javaMediumJava[Array, DP, Greedy, Sequence DP, Status DP]
406Random Pick Index.javaMediumJava[Reservior Sampling]
407Find the Celebrity.javaMediumJava[Array, Greedy]
408Sparse Matrix Multiplication.javaMediumJava[Hash Table]
409Brick Wall.javaMediumJava[Hash Table]
410Exclusive Time of Functions.javaMediumJava[Stack]
411Friends Of Appropriate Ages.javaMediumJava[Array, Math]
412Target Sum.javaMediumJava[DFS, DP]
413Maximum Size Subarray Sum Equals k.javaMediumJava[Hash Table, PreSum, Subarray]
414Contiguous Array.javaMediumJava[Hash Table]
415Line Reflection.javaMediumJava[Hash Table, Math]
416Insert Delete GetRandom O(1).javaMediumJava[Array, Design, Hash Table]
417Number of Longest Increasing Subsequence.javaMediumJava[Coordinate DP, DP]
418Minimum Swaps To Make Sequences Increasing.javaMediumJava[Coordinate DP, DP, Status DP]
419Binary Tree Vertical Order Traversal.javaMediumJava[BFS, DFS, Hash Table, Tree]
420Populating Next Right Pointers in Each Node II.javaMediumJava[DFS, Tree]
421Search in Rotated Sorted Array.javaMediumJava[Array, Binary Search]
422Minimum Subarray.javaEasyJava[Array, DP, Greedy, Sequence DP, Subarray]
423Valid Number.javaHardJava[Enumeration, Math, String]
424Find the Weak Connected Component in the Directed Graph.javaMediumJava[Union Find]
425Accounts Merge.javaMediumJava[DFS, Hash Table, Hash Table, Union Find]
426Bricks Falling When Hit.javaHardJava[Union Find]
427Interval Sum II.javaHardJava[Binary Search, Lint, Segment Tree]
428Count of Smaller Number.javaMediumJava[Binary Search, Lint, Segment Tree]
429HashHeap.javaHardJava[HashHeap, Heap]
430My Calendar I.javaMediumJava[Array, TreeMap]
431Reverse Pairs.javaMediumJava[Binary Indexed Tree, Binary Search Tree, Divide and Conquer, Merge Sort, Segment Tree]
432Trapping Rain Water II.javaHardJava[BFS, Heap, MinHeap, PriorityQueue]
433Kth Largest Element in an Array.javaMediumJava[Divide and Conquer, Heap, MinHeap, PriorityQueue, Quick Sort]
434Merge k Sorted Lists.javaMediumJava[Divide and Conquer, Heap, Linked List, PriorityQueue]
435Merge k Sorted Arrays.javaMediumJava[Heap, MinHeap, PriorityQueue]
436Heapify.javaMediumJava[Heap, MinHeap]
437Top K Frequent Elements.javaMediumJava[Hash Table, Heap, MaxHeap, MinHeap, PriorityQueue]
438Ugly Number II.javaMediumJava[DP, Enumeration, Heap, Math, PriorityQueue]
439Find Median from Data Stream.javaHardJava[Design, Heap, MaxHeap, MinHeap]
440Sliding Window Median.javaHardJava[Design, Heap, MaxHeap, MinHeap, Sliding Window]
441Inorder Successor in BST.javaMediumJava[BST, Tree]
442Subtree of Another Tree.javaEasyJava[DFS, Divide and Conquer, Tree]
443Two Sum IV – Input is a BST.javaEasyJava[Tree]
444Read N Characters Given Read4.javaEasyJava[Enumeration, String]
445Design Search Autocomplete System.javaHardJava[Design, Hash Table, MinHeap, PriorityQueue, Trie]
446Walls and Gates.javaMediumJava[BFS, DFS]
447Merge Sorted Array.javaEasyJava[Array, Two Pointers]
448Integer to English Words.javaHardJava[Enumeration, Math, String]
449Alien Dictionary.javaHardJava[BFS, Backtracking, DFS, Graph, Topological Sort]
450Valid Palindrome II.javaEasyJava[String]
451Convert Binary Search Tree to Sorted Doubly Linked List.javaMediumJava[BST, DFS, Divide and Conquer, Linked List, Tree]
452Word Ladder II.javaHardJava[Array, BFS, Backtracking, DFS, Hash Table, String]
453Moving Average from Data Stream.javaEasyJava[Design, Queue, Sliding Window]
454Move Zeroes.javaEasyJava[Array, Two Pointers]
455Flood Fill.javaEasyJava[DFS]
456Diameter of Binary Tree.javaEasyJava[Tree]
457Backspace String Compare.javaEasyJava[Stack, Two Pointers]
458Text Justification.javaHardJava[Enumeration, String]
459Read N Characters Given Read4 II – Call multiple times.javaHardJava[Enumeration, String]
460Frog Jump.javaHardJava[DP, Hash Table]
461Longest Substring with At Most Two Distinct Characters.javaHardJava[Hash Table, Sliding Window, String, Two Pointers]
462Shortest Distance from All Buildings.javaHardJava[BFS]
463String to Integer (atoi).javaMediumJava[Math, String]
464Roman to Integer.javaEasyJava[Math, String]
465Intersection of Two Arrays.javaEasyJava[Binary Search, Hash Table, Sort, Two Pointers]
466Strobogrammatic Number.javaEasyJava[Enumeration, Hash Table, Math]
467Valid Parentheses.javaEasyJava[Stack, String]
468First Unique Character in a String.javaEasyJava[Hash Table, String]
469Add Binary.javaEasyJava[Math, String, Two Pointers]
470Clone Graph.javaMediumJava[BFS, DFS, Graph]
471Sliding Window Maximum.javaHardJava[Deque, Heap, Sliding Window]
472Median of Two Sorted Arrays.javaHardJava[Array, Binary Search, DFS, Divide and Conquer]
473Permutations.javaMediumJava[Backtracking, DFS, Permutation]
474One Edit Distance.javaMediumJava[String]
4754Sum.javaMediumJava[Hash Table]
476Bus Routes.javaHardJava[BFS]
477Sliding Puzzle.javaHardJava[BFS, Graph]
478Isomorphic Strings.javaEasyJava[Hash Table]
479Cracking the Safe.javaHardJava[DFS, Greedy, Math]
480Redundant Connection.javaMediumJava[BFS, DFS, Graph, Tree, Union Find]
481Graph Valid Tree.javaMediumJava[BFS, DFS, Graph, Union Find]
482Redundant Connection II.javaHardJava[DFS, Graph, Tree, Union Find]
483The Maze.javaMediumJava[BFS, DFS]
484The Maze II.javaMediumJava[BFS, DFS, PriorityQueue]
485The Maze III.javaHardJava[BFS, DFS, PriorityQueue]
486Predict the Winner.javaMediumJava[DP, MiniMax]
487Next Greater Element I.javaEasyJava[Hash Table, Stack]
488Group Shifted Strings.javaMediumJava[Hash Table, String]
489Delete Digits.javaMediumJava[Greedy, Priority Queue]
490Flatten 2D Vector.javaMediumJava[Design]
491The Spiral Matrix II.javaMediumJava[Array]
492Regular Expression Matching.javaHardJava[Backtracking, DP, Double Sequence DP, Sequence DP, String]
493Wildcard Matching.javaHardJava[Backtracking, DP, Double Sequence DP, Greedy, Sequence DP, String]
494Robot Room Cleaner.javaHardJava[Backtracking, DFS]
495Maximum Vacation Days.javaHardJava[DP]
    原文作者:张土汪
    原文地址: https://www.jianshu.com/p/9e4fc9289e9b
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞