/LeetcodeEveryday

每日 Leetcode

Primary LanguageTeXGNU General Public License v2.0GPL-2.0

Leetcode 学习与总结

一、电子书(pdf)

Latex排版整理的电子书



二、文档列表



三、所有题目列表

# TitleEN TitleCN Level Java C++ Python Go Remark
1 Two Sum Java解答
2 Add Two Numbers Java解答
3 Longest Substring Without Repeating Characters Java解答 这个系列的所有题都要多做几遍
4 Median of Two Sorted Arrays Java解答 这题很经典,多做几遍
5 Longest Palindromic Substring Java解答 这题对比动态规划和最优算法
6 ZigZag Conversion Java解答
7 Reverse Integer Java解答
8 String to Integer (atoi) Java解答 很考代码能力,容易错
9 Palindrome Number Java解答
10 Regular Expression Matching Java解答 这题很经典,多做几遍,和#44一起
11 Container With Most Water Java解答
12 Integer to Roman Java解答
13 Roman to Integer Java解答
14 Longest Common Prefix Java解答
15 3Sum Java解答
16 3Sum Closest Java解答
17 Letter solution.Combinations of a Phone Number Java解答
18 4Sum Java解答
19 Remove Nth Node From End of List Java解答
20 Valid Parentheses Java解答
21 Merge Two Sorted Lists Java解答
22 Generate Parentheses Java解答 这题看两遍
23 Merge k Sorted Lists Java解答
24 Swap Nodes in Pairs Java解答
25 Reverse Nodes in k-Group Java解答
26 Remove Duplicates from Sorted Array Java解答
27 Remove Element Java解答
28 Implement strStr() Java解答
29 Divide Two Integers Java解答
30 Substring with Concatenation of All Words Java解答
31 Next Permutation Java解答
32 Longest Valid Parentheses Java解答
33 Search in Rotated Sorted Array Java解答
34 Search for a Range Java解答
35 Search Insert Position Java解答
36 Valid Sudoku Java解答
37 Sudoku Solver Java解答 这道题是典型的back tracking,多做几遍
38 Count and Say Java解答
39 Combination Sum Java解答 排列组合系列的题要多做几遍
40 Combination Sum II Java解答
41 First Missing Positive Java解答
42 Trapping Rain Water Java解答
43 Multiply Strings Java解答
44 Wildcard Matching Java解答 和#10多做几遍
45 Jump Game II Java解答
46 solution.Permutations Java解答
47 solution.Permutations II Java解答 多做几遍
48 Rotate Image Java解答
49 Group Anagrams Java解答
50 solution.Pow(x, n) Java解答
51 N-Queens Java解答
52 N-Queens II Java解答
53 Maximum Subarray Java解答
54 Spiral Matrix Java解答
55 Jump Game Java解答
56 Merge Intervals Java解答
57 Insert Interval Java解答 这题要多做几遍
60 Permutation Sequence Java解答 这题思路巧妙,多做两遍
61 Rotate List Java解答
66 Plus One Java解答 这题多看一遍
67 Add Binary Java解答
68 Text Justification Java解答
69 solution.Sqrt(x) Java解答
70 Climb Stairs 爬楼梯 easy Java解答
71 Simplify Path Java解答
72 Edit Distance Java解答
73 Set Matrix Zeroes Java解答
74 Search a 2D Matrix Java解答
75 Sort Colors Java解答 这题多做几遍,很有意思
76 Minimum Window Substring Java解答 这题以及类似的题一定要多做几遍,很经典,参见window
77 solution.Combinations Java解答
78 solution.Subsets Java解答
79 Word Search Java解答
80 Remove Duplicates from Sorted Array II Java解答
81 Search in Rotated Sorted Array II Java解答
82 Remove Duplicates from Sorted List II Java解答
83 Remove Duplicates from Sorted List Java解答
84 Largest Rectangle in Histogram Java解答
85 Maximal Rectangle Java解答
86 Partition List Java解答
88 Merge Sorted Array Java解答
90 solution.Subsets II Java解答
91 Decode Ways Java解答 这题多做几遍,包括#639
92 Reverse Linked List II Java解答
93 Restore IP Addresses Java解答 多看两遍
94 Binary Tree Inorder Traversal Java解答
95 Unique Binary Search Trees II Java解答 多做几遍,递归和DP
96 Unique Binary Search Trees Java解答
98 Validate Binary Search Tree Java解答 注意溢出
99 Recover Binary Search Tree Java解答 这题很容易错,要多做几遍
100 Same Tree Java解答
101 Symmetric Tree Java解答
102 Binary Tree Level Order Traversal Java解答
103 Binary Tree Zigzag Level Order Traversal Java解答
104 Maximum Depth of Binary Tree Java解答
105 Construct Binary Tree from Preorder and Inorder Traversal Java解答
106 Construct Binary Tree from Inorder and Postorder Traversal Java解答
107 Binary Tree Level Order Traversal II Java解答
108 Convert Sorted Array to Binary Search Tree Java解答
109 Convert Sorted List to Binary Search Tree Java解答
110 Balanced Binary Tree Java解答
111 Minimum Depth of Binary Tree Java解答
112 Path Sum Java解答
113 Path Sum II Java解答 错了好几次,得多做几遍
114 Flatten Binary Tree to Linked List Java解答
116 Populating Next Right Pointers in Each Node Java解答
117 Populating Next Right Pointers in Each Node II Java解答
118 Pascal's Triangle Java解答
119 Pascal's Triangle II Java解答
121 Best Time to Buy and Sell Stock Java解答
122 Best Time to Buy and Sell Stock II Java解答
123 Best Time to Buy and Sell Stock III Java解答
124 Binary Tree Maximum Path Sum Java解答
125 Valid Palindrome Java解答
126 Word Ladder II Java解答
127 Word Ladder Java解答 此题非常经典,务必连同ii多做几遍,将双端BFS吃透
128 Longest Consecutive Sequence Java解答
129 Sum Root to Leaf Numbers Java解答
130 Surrounded Regions Java解答
131 Palindrome Partitioning Java解答
132 Palindrome Partitioning II Java解答
133 Clone Graph Java解答 这题不难,多看两遍,BFS方法再做两遍
135 solution.Candy Java解答
138 Copy List with Random Pointer Java解答 有一个易错点
139 Word Break Java解答 多看两遍
140 Word Break II Java解答 这题多做两遍,很典型
141 Linked List Cycle Java解答
142 Linked List Cycle II Java解答
143 Reorder List Java解答
144 Binary Tree Preorder Traversal Java解答
145 Binary Tree Postorder Traversal Java解答
146 LRU Cache Java解答 好题目,多做几遍
147 Insertion Sort List Java解答
148 Sort List Java解答
149 Max Points on a Line Java解答
150 Evaluate Reverse Polish Notation Java解答
151 Reverse Words in a String Java解答 这题虽然不难,但是也错了几次
152 Maximum Product Subarray Java解答
153 Find Minimum in Rotated Sorted Array Java解答
154 Find Minimum in Rotated Sorted Array II Java解答
155 Min Stack Java解答
156 Binary Tree Upside Down Java解答 这道题挺有意思,多做几遍
157 Read N Characters Given Read4 Java解答 这题多做几遍,结合#158
158 Read N Characters Given Read4 II - Call multiple times Java解答
159 Longest Substring with At Most Two Distinct Characters Java解答 多看两遍
160 Intersection of Two Linked Lists Java解答
161 One Edit Distance Java解答 和#72做两遍
162 Find Peak Element Java解答
163 Missing Ranges Java解答 多做几遍,太容易错了
164 Maximum Gap Java解答
167 Two Sum II - Input array is sorted Java解答
168 Excel Sheet Column Title Java解答
169 Majority Element Java解答
170 Two Sum III - Data structure design Java解答 这道题再多做一遍
171 Excel Sheet Column Number Java解答
172 Factorial Trailing Zeroes Java解答
173 Binary Search Tree Iterator Java解答 多留意一下
179 Largest Number Java解答
186 Reverse Words in a String II Java解答
188 Best Time to Buy and Sell Stock IV Java解答
189 Rotate Array Java解答
190 Reverse Bits Java解答
198 House Robber Java解答
199 Binary Tree Right Side View Java解答
200 Number of Islands Java解答 这道题很经典,而且方法不止一种,每种方法都多做几遍,包括UF,#305
203 Remove Linked List Elements Java解答
204 Count Primes Java解答
206 Reverse Linked List Java解答
207 Course Schedule Java解答 典型的拓扑排序
208 Implement solution.Trie (Prefix Tree) Java解答 和#211多留意,trie很典型
209 Minimum Size Subarray Sum Java解答
210 Course Schedule II Java解答
211 Add and Search Word - Data structure design Java解答
212 Word Search II Java解答
213 House Robber II Java解答
214 Shortest Palindrome Java解答
215 Kth Largest Element in an Array Java解答 这题很经典,三种解法都要了然于胸
216 Combination Sum III Java解答
217 Contains Duplicate Java解答
218 The Skyline Problem Java解答 这题多做两遍
219 Contains Duplicate II Java解答
220 Contains Duplicate III Java解答
221 Maximal Square Java解答
222 Count Complete Tree Nodes Java解答 一般的做法会超时
223 Rectangle Area Java解答
224 Basic Calculator Java解答
225 Implement Stack using Queues Java解答
226 Invert Binary Tree Java解答
228 Summary Ranges Java解答
229 Majority Element II Java解答
230 Kth Smallest Element in a BST Java解答 注意Follow Up
232 Implement Queue using Stacks Java解答
233 Number of Digit One Java解答
234 Palindrome Linked List Java解答
235 Lowest Common Ancestor of a Binary Search Tree Java解答
236 Lowest Common Ancestor of a Binary Tree Java解答 这题很经典,多做几遍,留意节点不在树中的情况
237 Delete Node in a Linked List Java解答
238 Product of Array Except Self Java解答
239 Sliding Window Maximum Java解答 这题非常经典,多做几遍,包括常规算法(优先队列,treemap)及优化算法双端队列
240 Search a 2D Matrix II Java解答
241 Different Ways to Add Parentheses Java解答
242 Valid Anagram Java解答
243 Shortest Word Distance Java解答
244 Shortest Word Distance II Java解答
245 Shortest Word Distance III Java解答
246 Strobogrammatic Number Java解答 #247一个系列,多看两遍
247 Strobogrammatic Number II Java解答 多看两遍
249 Group Shifted Strings Java解答
250 Count Univalue Subtrees Java解答 这题要多做几遍
251 Flatten 2D Vector Java解答
252 Meeting Rooms Java解答
253 Meeting Rooms II Java解答
254 Factor solution.Combinations Java解答
255 Verify Preorder Sequence in Binary Search Tree Java解答 很简单,粗心错了
256 Paint House Java解答
257 Binary Tree Paths Java解答
259 3Sum Smaller Java解答 这题虽然简单,但是因为思维定式还是错了几次
261 Graph Valid Tree Java解答 这题多做几遍
263 Ugly Number Java解答
264 Ugly Number II Java解答
265 Paint House II Java解答
266 Palindrome Permutation Java解答
267 Palindrome Permutation II Java解答 典型,多看两遍
268 Missing Number Java解答
269 Alien Dictionary Java解答 这题要多做几遍
270 Closest Binary Search Tree Value Java解答
271 Encode and Decode Strings Java解答 思路巧妙,多看几遍
272 Closest Binary Search Tree Value II Java解答 这题非常值得多做几遍,几种写法都试试
273 Integer to English Words Java解答 多做几遍,做到bug free
274 H-Index Java解答
275 H-Index II Java解答
277 Find the Celebrity Java解答
278 First Bad Version Java解答
279 Perfect Squares Java解答
280 Wiggle Sort Java解答 思路巧妙,多看两遍
281 Zigzag Iterator Java解答 多做三遍,考虑扩展到k的情况
282 Expression Add Operators Java解答
283 Move Zeroes Java解答
284 Peeking Iterator Java解答
285 Inorder Successor in BST Java解答 这道题有意思,要多做几遍
286 Walls and Gates Java解答 多看两遍
287 Find the Duplicate Number Java解答
288 Unique Word Abbreviation Java解答 这题不难,多做两遍,题目意思容易理解错
289 Game of Life Java解答
293 Flip Game Java解答
294 Flip Game II Java解答
295 Find Median from Data Stream Java解答
297 Serialize and Deserialize Binary Tree Java解答 好题目,多做做,递归的非递归的
298 Binary Tree Longest Consecutive Sequence Java解答 多做三遍,尽可能简洁
299 Bulls and Cows Java解答
300 Longest Increasing Subsequence Java解答
301 Remove Invalid Parentheses Java解答 比较难,多做几遍
302 Smallest Rectangle Enclosing Black Pixels Java解答
303 Range Sum Query - Immutable Java解答
304 Range Sum Query 2D - Immutable Java解答
305 Number of Islands II Java解答 这题多做几遍,经典的UF
307 Range Sum Query - Mutable Java解答 和#303, #304, #308定要多做几遍,掌握BIT
308 Range Sum Query 2D - Mutable Java解答
309 Best Time to Buy and Sell Stock with Cooldown Java解答
310 Minimum Height Trees Java解答 这题多做几遍
311 Sparse Matrix Multiplication Java解答
312 Burst Balloons Java解答
313 Super Ugly Number Java解答
314 Binary Tree Vertical Order Traversal Java解答
315 Count of Smaller Numbers After Self Java解答
316 Remove Duplicate Letters Java解答
317 Shortest Distance from All Buildings Java解答 典型的bfs,多做两遍
319 Bulb Switcher Java解答
320 Generalized Abbreviation Java解答 这题是典型的back tracking,多做几遍
322 Coin Change Java解答
323 Number of Connected Components in an Undirected Graph Java解答 典型的图,多看两遍
324 Wiggle Sort II Java解答
325 Maximum Size Subarray Sum Equals k Java解答 这题思路有意思,多做几遍
328 Odd Even Linked List Java解答
329 Longest Increasing Path in a Matrix Java解答 这题要多做几遍
332 Reconstruct Itinerary Java解答
333 Largest BST Subtree Java解答 这道题虽然不难,但是折腾了很久,一定要多做
334 Increasing Triplet Subsequence Java解答
335 Self Crossing Java解答
336 Palindrome Pairs Java解答
337 House Robber III Java解答 建议再做两遍
339 Nested List Weight Sum Java解答
340 Longest Substring with At Most K Distinct Characters Java解答 和#159类似
341 Flatten Nested List Iterator Java解答 这题有点意思,多做两遍
344 Reverse String Java解答
345 Reverse Vowels of a String Java解答
346 Moving Average from Data Stream Java解答
347 Top K Frequent Elements Java解答
349 Intersection of Two Arrays Java解答
350 Intersection of Two Arrays II Java解答
351 Android Unlock Patterns Java解答 这题多做几遍
357 Count Numbers with Unique Digits Java解答
358 Rearrange String k Distance Apart Java解答
359 Logger Rate Limiter Java解答 这题如果不考虑空间消耗的话其实很简单
361 Bomb Enemy Java解答 这题多做几遍,开始没思路
364 Nested List Weight Sum II Java解答
366 Find Leaves of Binary Tree Java解答 这道题刚开始还没思路
367 Valid Perfect Square Java解答
369 Plus One Linked List Java解答
370 Range Addition Java解答
373 Find K Pairs with Smallest Sums Java解答
374 Guess Number Higher or Lower Java解答
375 Guess Number Higher or Lower II Java解答
377 Combination Sum IV Java解答
378 Kth Smallest Element in a Sorted Matrix Java解答
380 Insert Delete GetRandom O(1) Java解答 这道题很有意思,多做几遍
381 Insert Delete GetRandom O(1) - Duplicates allowed Java解答
382 Linked List Random Node Java解答
384 Shuffle an Array Java解答
387 First Unique Character in a String Java解答
388 Longest Absolute File Path Java解答 其实不难,乍看没思路,多做几遍
391 Perfect Rectangle Java解答 这题很trick,多做两遍
393 UTF-8 Validation Java解答 错了很多次,多做几遍
394 Decode String Java解答 这题容易错,多做四遍
395 Longest Substring with At Least K Repeating Characters Java解答
398 Random Pick Index Java解答
399 Evaluate Division Java解答 这题多做几遍
401 Binary Watch Java解答
404 Sum of Left Leaves Java解答
406 Queue Reconstruction by Height Java解答 这题开始没思路,多做几遍
407 Trapping Rain Water II Java解答
408 Valid Word Abbreviation Java解答 多做两遍
409 Longest Palindrome Java解答
410 Split Array Largest Sum Java解答
412 Fizz Buzz Java解答
413 Third Maximum Number Java解答
418 Sentence Screen Fitting Java解答 这题思路巧妙,多做几遍,常规思路超时
422 Valid Word Square Java解答
425 Word Squares Java解答 这题很典型,多做几遍
436 Find Right Interval Java解答
437 Path Sum III Java解答 这道题错了很多遍,要重点关注
438 Find All Anagrams in a String Java解答 这道题非常经典,最优解法需要多做几遍,保证once bug free
442 Find All Duplicates in an Array Java解答
445 Add Two Numbers II Java解答
448 Find All Numbers Disappeared in an Array Java解答
449 Serialize and Deserialize BST Java解答 和#297一样
450 Delete Node in a BST Java解答 这题非常经典,值得多做十遍
451 Sort Characters By Frequency Java解答
459 Repeated Substring Pattern Java解答
477 Total Hamming Distance Java解答
480 Sliding Window Median Java解答
482 License Key Formatting Java解答
483 Smallest Good Base Java解答
485 Max Consecutive Ones Java解答
487 Max Consecutive Ones II Java解答
501 Find Mode in Binary Search Tree Java解答 不难,容易错,多做两次
508 Most Frequent Subtree Sum Java解答
513 Find Bottom Left Tree Value Java解答
515 Find Largest Value in Each Tree Row Java解答
524 Longest Word in Dictionary through Deleting Java解答
526 Beautiful Arrangement Java解答
535 Encode and Decode TinyURL Java解答
538 Convert BST to Greater Tree Java解答
541 Reverse String II Java解答
543 Diameter of Binary Tree Java解答 这题易错
547 Friend Circles Java解答
557 Reverse Words in a String III Java解答
560 Subarray Sum Equals K Java解答
563 Binary Tree Tilt Java解答
564 Find the Closest Palindrome Java解答 此题暴力法即可
572 Subtree of Another Tree Java解答
606 Construct String from Binary Tree Java解答
617 Merge Two Binary Trees Java解答 很简单
621 Task Scheduler Java解答
637 Average of Levels in Binary Tree Java解答
652 Find Duplicate Subtrees Java解答 开始还没思路
653 Two Sum IV - Input is a BST Java解答
654 Maximum Binary Tree Java解答
669 Trim a Binary Search Tree Java解答
681 Next Closest Time Java解答 这题多做几遍
683 K Empty Slots Java解答
684 Redundant Connection Java解答
687 Longest Univalue Path Java解答
695 Max Area of Island Java解答
703 Kth Largest Element in a Stream Java解答
771 Jewels and Stones Java解答
814 Binary Tree Pruning Java解答
819 Most Common Word Java解答
843 Guess the Word Java解答
844 Backspace String Compare Java解答
849 Maximize Distance to Closest Person Java解答
857 Minimum Cost to Hire K Workers Java解答
872 Leaf-Similar Trees Java解答
889 Construct Binary Tree from Preorder and Postorder Traversal Java解答
904 Fruit Into Baskets Java解答
929 Unique Email Addresses Java解答