leetcode

关于LeetCode 上的题目解析

LeetCode Algorithms

No. Title Solutions Difficulty Related Topics Time Complexity Space Complexity Tag
867 Transpose Matrix Java Easy Array O(n) O(1)  
859 Buddy Strings Java Easy String O(n)    
858 Mirror Reflection Java Medium Math      
852 Peak Index in a Mountain Array Java Easy Binary Search      
848 Shifting Letters Java Medium String O(n) O(1)  
846 Hand of Straights Java
Python
Medium Map O(nlogn)    
844 Backspace String Compare Java Easy Two Pointers Stack      
832 Flipping an Image Java Easy Array O(n) O(n)  
819 Most Common Word Java Easy String O(n)   γ
812 Largest Triangle Area Java Easy Math O(n^3)   links
804 Unique Morse Code Words Java Scala Easy String O(n) O(n)
781 Rabbits in Forest Java Medium HashTable Math O(n) O(1)  
771 Jewels and Stones Java Easy HashTable O(n*m)    
763 Partition Labels Java Medium Two Pointer Greedy O(n) O(1)  
713 Subarray Product Less Than K Java Medium Array Two Poniter O(n) O(1)  
704 Binary Search Java Easy Binary Search O(logn) O(1)  
696 Robot Return to Origin Java Easy String O(n) O(1) links
661 Image Smoother Java Easy Array O(n*m) O(1)  
657 Robot Return to Origin Java Easy String      
653 Two Sum IV - Input is a BST Java Easy Tree O(n)   γ
643 Maximum Average Subarray I Java Easy Array O(n)   γ
637 Average of Levels in Binary Tree Java Easy Tree BFS      
622 Design Circular Queue Java Medium Design Queue O(n) O(1) 循环队列
599 Minimum Index Sum of Two Lists Java Easy Hash Table O(n)    
561 Array Partition I Java Easy Array      
477 Total Hamming Distance Java Medium Bit Manipulation O(n) O(1) links
418 SentenceScreenFitting   Easy       Locked
416 Partition Equal Subset Sum Java Medium        
415 Add Strings Java Easy Math O(n)    
414 Third Maximum Number Java Easy Array O(n) O(1)  
413 Arithmetic Slices Java Medium        
412 Fizz Buzz Java Easy        
410 Split Array Largest Sum Java Hard        
409 Longest Palindrome Java Easy        
406 Queue Reconstruction by Height Java Medium        
405 Convert a Number to Hexadecimal Java Easy        
404 Sum of Left Leaves Java Easy        
403 Frog Jump Java Hard        
402 Remove K Digits Java Medium        
401 Binary Watch Java Easy        
400 Nth Digit Java Easy        
399 Evaluate Division Java Medium        
398 Random Pick Index Java Medium        
397 Integer Replacement Java Medium        
396 Rotate Function Java Easy        
395 Longest Substring with At Least K Repeating Characters Java Medium        
394 Decode String Java Medium        
393 UTF-8 Validation Java Medium        
392 Is Subsequence Java Medium        
391 Perfect Rectangle Java Hard        
390 Elimination Game Java Medium        
389 Find the Difference Java Easy        
388 Longest Absolute File Path Java Medium        
387 First Unique Character in a String Java Easy Hash Table String O(n) O(1)  
386 Lexicographical Numbers Java Medium        
385 Mini Parser Java Medium        
384 Shuffle an Array Java Medium        
383 Ransom Note Java Easy        
382 Linked List Random Node Java Medium        
381 Insert Delete GetRandom O(1) - Duplicates allowed Java Hard        
380 Insert Delete GetRandom O(1) Java Hard        
377 Combination Sum IV Java Medium        
376 Wiggle Subsequence Java Medium        
371 Sum of Two Integers Java Easy        
367 Valid Perfect Square Java Easy        
350 Intersection of Two Arrays II Java Easy        
349 Intersection of Two Arrays Java Easy        
347 Top K Frequent Elements Java Medium        
345 Reverse Vowels of a String Java Easy        
344 Reverse String Java Easy        
343 Integer Break Java Medium        
342 Power of Four Java Easy        
341 Flatten Nested List Iterator Java Medium        
338 Counting Bits Java Medium        
337 House Robber III Java Medium        
336 Palindrome Pairs Java Hard        
334 Increasing Triplet Subsequence Java Medium        
332 Reconstruct Itinerary Java Medium        
331 Verify Preorder Serialization of a Binary Tree Java Medium        
330 Patching Array Java Medium        
329 Longest Increasing Path in a Matrix Java Medium        
328 Odd Even Linked List Java Easy        
327 Count of Range Sum Java Hard        
326 Power of Three Java Easy        
324 Wiggle Sort II Java Medium        
322 Coin Change Java Medium        
321 Create Maximum Number Java Hard        
319 Bulb Switcher Java Medium        
318 Maximum Product of Word Lengths Java Medium        
316 Remove Duplicate Letters Java Hard        
315 Count of Smaller Numbers After Self Java Hard        
313 Super Ugly Number Java Medium        
312 Burst Balloons Java Hard        
310 Minimum Height Trees Java Medium        
307 Range Sum Query - Mutable Java Medium        
306 Additive Number Java Medium        
304 Range Sum Query 2D - Immutable Java Medium        
303 Range Sum Query - Immutable Java Easy        
301 Remove Invalid Parentheses Java Hard        
300 Longest Increasing Subsequence Java Medium        
299 Bulls and Cows Java Easy        
297 Serialize and Deserialize Binary Tree Java Medium        
295 Find Median from Data Stream Java Hard        
292 Nim Game Java Easy        
290 Word Pattern Java Easy        
287 Find the Duplicate Number Java Hard        
285 Inorder Successor in BST   Medium       locked
284 Peeking Iterator Java Medium        
283 Move Zeroes Java Easy        
282 Expression Add Operators Java Hard        
279 Perfect Squares Java Medium        
278 First Bad Version Java Easy Binary Search O(logn) O(1) γ
275 H-Index II Java Medium        
274 H-Index Java Medium        
273 Integer to English Words Java Medium        
268 Missing Number Java Medium        
264 Ugly Number II Java Medium        
263 Ugly Number Java Easy        
260 Single Number III Java Medium        
258 Add Digits Java Easy        
257 Binary Tree Paths Java Easy        
242 Valid Anagram Java Easy        
241 Different Ways to Add Parentheses Java Medium        
240 Search a 2D Matrix II Java Medium        
239 Sliding Window Maximum Java Hard        
238 Product of Array Except Self Java Medium        
237 Delete Node in a Linked List Java Easy        
236 Lowest Common Ancestor of a Binary Tree Java, Scala Medium        
235 Lowest Common Ancestor of a Binary Search Tree Java Easy        
234 Palindrome Linked List Java Easy        
233 Number of Digit One Java Medium        
232 Implement Queue using Stacks Java Easy Stack Design O(1) O(1)  
231 Power of Two Java Easy        
230 Kth Smallest Element in a BST Java Medium        
229 Majority Element II Java Medium        
228 Summary Ranges Java Easy        
227 Basic Calculator II Java Medium        
226 Invert Binary Tree Java Easy        
225 Implement Stack using Queues Java Medium        
224 Basic Calculator Java Medium        
223 Rectangle Area Java Easy        
222 Count Complete Tree Nodes Java Medium        
221 Maximal Square Java Medium        
220 Contains Duplicate III Java Medium        
219 Contains Duplicate II Java Easy        
218 The Skyline Problem Java Hard        
217 Contains Duplicate Java Easy        
216 Combination Sum III Java Medium        
215 Kth Largest Element in an Array Java Medium        
214 Shortest Palindrome Java Hard        
213 House Robber II Java Medium        
212 Word Search II Java Hard        
211 Add and Search Word - Data structure design Java Medium        
210 Course Schedule II Java Medium        
209 Minimum Size Subarray Sum Java Medium        
208 Implement Trie (Prefix Tree) Java Medium        
207 Course Schedule Java Medium        
206 Reverse Linked List Java, Java Easy        
205 Isomorphic Strings Java Easy        
204 Count Primes Java Easy        
203 Remove Linked List Elements Java Easy        
202 Happy Number Java Easy        
201 Bitwise AND of Numbers Range Java Medium        
200 Number of Islands Java Medium        
199 Binary Tree Right Side View Java Medium O(nlogn)   Tree DFS BFS  
198 House Robber Java Easy        
195             shell
194             shell
193             shell
192             shell
191 Number of 1 Bits Java Easy        
190 Reverse Bits Java Easy        
189 Rotate Array Java, Scala Easy        
188 Best Time to Buy and Sell Stock IV Java Hard        
187 Repeated DNA Sequences Java Medium        
186 Reverse Words in a String II   Medium       locked
179 Largest Number Java Medium        
174 Dungeon Game Java Hard        
173 Binary Search Tree Iterator Java, Scala Medium        
172 Factorial Trailing Zeroes Java Easy        
171 Excel Sheet Column Number Java Easy        
170 Two Sum III - Data structure design Java Easy        
169 Majority Element Java Easy        
168 Excel Sheet Column Title Java Easy        
167 Two Sum II - Input array is sorted Java Easy Two Pointer
Array
Binary Search
O(n) O(1)  
166 Fraction to Recurring Decimal Java Medium        
165 Compare Version Numbers Java Easy        
164 Maximum Gap Java Hard        
163 Missing Ranges Java Medium        
162 Find Peak Element Java Medium        
161 One Edit Distance Java Medium        
160 Intersection of Two Linked Lists Java Easy        
159 Longest Substring with At Most Two Distinct Characters Java Hard        
158 Read N Characters Given Read4 II - Call multiple times Java Hard        
157 Read N Characters Given Read4 Java Easy        
156 Binary Tree Upside Down Java Medium        
155 Min Stack Java, Scala Easy        
154 Find Minimum in Rotated Sorted Array II Java Hard        
153 Find Minimum in Rotated Sorted Array Java, Java Medium        
152 Maximum Product Subarray Java Medium        
151 Reverse Words in a String Java, Java Medium        
150 Evaluate Reverse Polish Notation Java Medium        
149 Max Points on a Line Java Hard        
148 Sort List Java Medium        
147 Insertion Sort List Java Medium        
146 LRU Cache Java, Scala Hard        
145 Binary Tree Postorder Traversal Java Hard        
144 Binary Tree Preorder Traversal Java, Java Medium        
143 Reorder List Java Medium        
142 Linked List Cycle II Java Medium        
141 Linked List Cycle Java Medium        
140 Word Break II Java Hard        
139 Word Break Java Medium        
138 Copy List with Random Pointer Java Hard        
137 Single Number II Java Medium        
136 Single Number Java Medium        
135 Candy Java Hard        
134 Gas Station Java Medium        
133 Clone Graph Java Medium        
132 Palindrome Partitioning II Java Hard        
131 Palindrome Partitioning Java Medium        
130 Surrounded Regions Java Medium        
129 Sum Root to Leaf Numbers Java Medium        
128 Longest Consecutive Sequence Java Hard        
127 Word Ladder Java Medium        
126 Word Ladder II Java Hard        
125 Valid Palindrome Java, Scala Easy        
124 Binary Tree Maximum Path Sum Java, Scala Hard        
123 Best Time to Buy and Sell Stock III Java Hard        
122 Best Time to Buy and Sell Stock II Java Medium        
121 Best Time to Buy and Sell Stock Java Medium        
120 Triangle Java, Java Medium        
119 Pascal’s Triangle II Java Easy        
118 Pascal’s Triangle Java Easy        
117 Populating Next Right Pointers in Each Node II Java Hard        
116 Populating Next Right Pointers in Each Node Java Medium        
115 Distinct Subsequences Java Hard        
114 Flatten Binary Tree to Linked List Java Medium        
113 Path Sum II Java Medium        
112 Path Sum Java Easy        
111 Minimum Depth of Binary Tree Java Easy        
110 Balanced Binary Tree Java, Java Easy        
109 Convert Sorted List to Binary Search Tree Java Medium        
108 Convert Sorted Array to Binary Search Tree Java Medium        
107 Binary Tree Level Order Traversal II Java Easy        
106 Construct Binary Tree from Inorder and Postorder Traversal Java Medium        
105 Construct Binary Tree from Preorder and Inorder Traversal Java Medium        
104 Maximum Depth of Binary Tree Java, Scala Easy        
103 Binary Tree Zigzag Level Order Traversal Java Medium        
102 Binary Tree Level Order Traversal Java, Scala Easy        
101 Symmetric Tree Java Easy Tree
Breadth-first Search
Depth-first Search
O(nlogn)    
100 Same Tree Java Easy Tree Depth-first Search O(nlogn)    
99 Recover Binary Search Tree Java Hard        
98 Validate Binary Search Tree Java, Scala Medium        
97 Interleaving String Java Hard        
96 Unique Binary Search Trees Java Medium        
95 Unique Binary Search Trees II Java Medium        
94 Binary Tree Inorder Traversal Java Medium        
93 Restore IP Addresses Java Medium        
92 Reverse Linked List II Java, Scala Medium        
91 Decode Ways Java Medium        
90 Subsets II Java Medium        
89 Gray Code Java Medium        
88 Merge Sorted Array Java Easy        
87 Scramble String Java Hard        
86 Partition List Java Medium        
85 Maximal Rectangle Java Hard        
84 Largest Rectangle in Histogram Java Hard        
83 Remove Duplicates from Sorted List Java Easy        
82 Remove Duplicates from Sorted List II Java Medium        
81 Search in Rotated Sorted Array II Java Medium        
80 Remove Duplicates from Sorted Array II Java Medium        
79 Word Search Java Medium        
78 Subsets Java, Scala Medium        
77 Combinations Java Medium        
76 Minimum Window Substring Java Hard        
75 Sort Colors Java Medium        
74 Search a 2D Matrix Java, Scala Medium        
73 Set Matrix Zeroes Java Medium        
72 Edit Distance Java Hard        
71 Simplify Path Java Medium        
70 Climbing Stairs Java Easy        
69 Sqrt(x) Java Medium        
68 Text Justification Java Hard        
67 Add Binary Java Easy        
66 Plus One Java Easy Array Math O(n) O(1)  
65 Valid Number Java Easy        
64 Minimum Path Sum Java Medium Array
Dynamic Programming
O(M*N) O(1)  
63 Unique Paths II Java Medium Array
Dynamic Programming
O(w*h) O(1)  
62 Unique Paths Java, Scala Medium        
61 Rotate List Java Medium        
60 Permutation Sequence Java Medium        
59 Spiral Matrix II Java Medium Array O(n^2) O(1)  
58 Length of Last Word Java Easy        
57 Insert Interval Java Hard        
56 Merge Intervals Java Hard        
55 Jump Game Java Medium Array
Greedy
O(n) O(1) Q45
54 Spiral Matrix Java Medium        
53 Maximum Subarray Java Medium Array
Dynamic Programming
Divide and Conquer
O(n)    
52 N-Queens II Java Hard        
51 N-Queens Java Hard        
50 “Pow(x, n)” Java Medium        
49 Group Anagrams Java Medium        
48 Rotate Image Java Medium        
47 Permutations II Java Hard        
46 Permutations Java Medium        
45 Jump Game II Java Hard Array Greedy O(n) O(1) Q55
44 Wildcard Matching Java Hard        
43 Multiply Strings Java Medium        
42 Trapping Rain Water Java Hard        
41 First Missing Positive Java Hard Array O(n) O(1) 分桶
40 Combination Sum II Java Medium        
39 Combination Sum Java Medium        
38 Count and Say Java Easy        
37 Sudoku Solver Java Hard        
36 Valid Sudoku Java Easy        
35 Search Insert Position Java Easy Array Binary Search O(N)    
34 Find First and Last Position of Element in Sorted Array Java Medium Array Binary Search O(n) O(1)  
33 Search in Rotated Sorted Array Java Medium Array Binary Search O(logn) O(1) 二分查找法
32 Longest Valid Parentheses Java Hard String Dynamic Programming      
31 Next Permutation Java Medium        
30 Substring with Concatenation of All Words Java Hard String Hash Table Two Pointer O(M*N)    
29 Divide Two Integers Java Medium        
28 Implement strStr() Java, Scala Easy        
27 Remove Element Java Easy        
26 Remove Duplicates from Sorted Array Java Easy Array Two Pointer O(n) O(1)  
25 Reverse Nodes in k-Group Java Hard        
24 Swap Nodes in Pairs Java Medium        
23 Merge k Sorted Lists Java Hard        
22 Generate Parentheses Java Medium        
21 Merge Two Sorted Lists Java Easy        
20 Valid Parentheses Java Easy String Stack O(n)    
19 Remove Nth Node From End of List Java Medium Linked List Two Pointer O(N)   γ
18 4Sum Java Medium Array HashTable TwoPointer O(N^4)   Q15
17 Letter Combinations of a Phone Number Java Medium String BackTracking O(n^3)   queue
16 3Sum Closest Java Medium Array Two Point O(n^2)   Q15
15 3Sum Java Medium Array Two Point O(n^2)   good γ
14 Longest Common Prefix Java Easy String O(M*N)    
13 Roman to Integer Java Easy Math String     Q12
12 Integer to Roman Java Medium Math String     Q13
11 Container With Most Water Java Medium        
10 Regular Expression Matching Java Hard String
Dynamic Programming
Backtracking
     
9 Palindrome Number Java Easy Math O(n) O(1) 回文
8 String to Integer (atoi) Java Medium Math
String
     
7 Reverse Integer Java Scala Easy Math      
6 ZigZag Conversion Java Medium String      
5 Longest Palindromic Substring Java Medium String
Dynamic Programming
     
4 Median of Two Sorted Arrays Java Hard        
3 Longest Substring Without Repeating Characters Java Medium        
2 Add Two Numbers Java Medium        
1 Two Sum Python Java Scala Easy Array HashTable      

LeetCode Shell

# Title Solution Difficulty
195 Tenth Line   Easy
194 Transpose File   Medium
193 Valid Phone Numbers   Easy
192 Word Frequency   Medium

LeetCode Database

| # | Title | Solution | Difficulty | |—| —– | ——– | ———- | | | | | |

其他

文件名称与编号匹配,并且将题目描述添加在该文件中,避免题目上锁不能查看 。