LeetCode All in One题解汇总(持续更新中...)

时间:2021-08-02 16:06:45

突然很想刷刷题,LeetCode是一个不错的选择,忽略了输入输出,更好的突出了算法,省去了不少时间。

dalao们发现了任何错误,或是代码无法通过,或是有更好的解法,或是有任何疑问和建议的话,可以在对应的随笔下面评论区留言,我会及时处理,在此谢过了。

过程或许会很漫长,也很痛苦,慢慢来吧。

编号 题名 过题率 难度
1 Two Sum 0.376 Easy
2 Add Two Numbers 0.285 Medium
3 Longest Substring Without Repeating Characters 0.247 Medium
4 Median of Two Sorted Arrays 0.229 Hard
5 Longest Palindromic Substring 0.252 Medium
6 ZigZag Conversion 0.272 Medium
7 Reverse Integer 0.244 Easy
8 String to Integer (atoi) 0.140 Medium
9 Palindrome Number 0.357 Easy
10 Regular Expression Matching 0.243 Hard
11 Container With Most Water 0.371 Medium
12 Integer to Roman 0.461 Medium
13 Roman to Integer 0.478 Easy
14 Longest Common Prefix 0.316 Easy
15 3Sum 0.218 Medium
16 3Sum Closest 0.316 Medium
17 Letter Combinations of a Phone Number 0.363 Medium
18 4Sum 0.275 Medium
19 Remove Nth Node From End of List 0.340 Medium
20 Valid Parentheses 0.339 Easy
21 Merge Two Sorted Lists 0.408 Easy
22 Generate Parentheses 0.477 Medium
23 Merge k Sorted Lists 0.280 Hard
24 Swap Nodes in Pairs 0.390 Medium
25 Reverse Nodes in k-Group 0.315 Hard
26 Remove Duplicates from Sorted Array 0.362 Easy
27 Remove Element 0.406 Easy
28 Implement strStr() 0.289 Easy
29 Divide Two Integers 0.158 Medium
30 Substring with Concatenation of All Words 0.223 Hard
31 Next Permutation 0.290 Medium
32 Longest Valid Parentheses 0.232 Hard
33 Search in Rotated Sorted Array 0.319 Medium
34 Search for a Range 0.316 Medium
35 Search Insert Position 0.400 Easy
36 Valid Sudoku 0.374 Medium
37 Sudoku Solver 0.319 Hard
38 Count and Say 0.366 Easy
39 Combination Sum 0.411 Medium
40 Combination Sum II 0.357 Medium
41 First Missing Positive 0.258 Hard
42 Trapping Rain Water 0.375 Hard
43 Multiply Strings 0.279 Medium
44 Wildcard Matching 0.209 Hard
45 Jump Game II 0.261 Hard
46 Permutations 0.469 Medium
47 Permutations II 0.348 Medium
48 Rotate Image 0.415 Medium
49 Group Anagrams 0.381 Medium
50 Pow(x, n) 0.260 Medium
51 N-Queens 0.331 Hard
52 N-Queens II 0.466 Hard
53 Maximum Subarray 0.402 Easy
54 Spiral Matrix 0.271 Medium
55 Jump Game 0.295 Medium
56 Merge Intervals 0.318 Medium
57 Insert Interval 0.289 Hard
58 Length of Last Word 0.320 Easy
59 Spiral Matrix II 0.409 Medium
60 Permutation Sequence 0.294 Medium
61 Rotate List 0.244 Medium
62 Unique Paths 0.426 Medium
63 Unique Paths II 0.321 Medium
64 Minimum Path Sum 0.404 Medium
65 Valid Number 0.129 Hard
66 Plus One 0.396 Easy
67 Add Binary 0.339 Easy
68 Text Justification 0.199 Hard
69 Sqrt(x) 0.288 Easy
70 Climbing Stairs 0.411 Easy
71 Simplify Path 0.262 Medium
72 Edit Distance 0.325 Hard
73 Set Matrix Zeroes 0.365 Medium
74 Search a 2D Matrix 0.347 Medium
75 Sort Colors 0.388 Medium
76 Minimum Window Substring 0.267 Hard
77 Combinations 0.411 Medium
78 Subsets 0.443 Medium
79 Word Search 0.280 Medium
80 Remove Duplicates from Sorted Array II 0.367 Medium
81 Search in Rotated Sorted Array II 0.327 Medium
82 Remove Duplicates from Sorted List II 0.299 Medium
83 Remove Duplicates from Sorted List 0.402 Easy
84 Largest Rectangle in Histogram 0.275 Hard
85 Maximal Rectangle 0.295 Hard
86 Partition List 0.334 Medium
87 Scramble String 0.297 Hard
88 Merge Sorted Array 0.321 Easy
89 Gray Code 0.423 Medium
90 Subsets II 0.381 Medium
91 Decode Ways 0.203 Medium
92 Reverse Linked List II 0.313 Medium
93 Restore IP Addresses 0.284 Medium
94 Binary Tree Inorder Traversal 0.493 Medium
95 Unique Binary Search Trees II 0.322 Medium
96 Unique Binary Search Trees 0.418 Medium
97 Interleaving String 0.251 Hard
98 Validate Binary Search Tree 0.240 Medium
99 Recover Binary Search Tree 0.309 Hard
100 Same Tree 0.477 Easy
101 Symmetric Tree 0.402 Easy
102 Binary Tree Level Order Traversal 0.423 Medium
103 Binary Tree Zigzag Level Order Traversal 0.366 Medium
104 Maximum Depth of Binary Tree 0.545 Easy
105 Construct Binary Tree from Preorder and Inorder Traversal 0.338 Medium
106 Construct Binary Tree from Inorder and Postorder Traversal 0.333 Medium
107 Binary Tree Level Order Traversal II 0.419 Easy
108 Convert Sorted Array to Binary Search Tree 0.442 Easy
109 Convert Sorted List to Binary Search Tree 0.355 Medium
110 Balanced Binary Tree 0.383 Easy
111 Minimum Depth of Binary Tree 0.335 Easy
112 Path Sum 0.348 Easy
113 Path Sum II 0.354 Medium
114 Flatten Binary Tree to Linked List 0.364 Medium
115 Distinct Subsequences 0.322 Hard
116 Populating Next Right Pointers in Each Node 0.369 Medium
117 Populating Next Right Pointers in Each Node II 0.339 Medium
118 Pascal's Triangle 0.399 Easy
119 Pascal's Triangle II 0.381 Easy
120 Triangle 0.348 Medium
121 Best Time to Buy and Sell Stock 0.428 Easy
122 Best Time to Buy and Sell Stock II 0.478 Easy
123 Best Time to Buy and Sell Stock III 0.303 Hard
124 Binary Tree Maximum Path Sum 0.271 Hard
125 Valid Palindrome 0.269 Easy
126 Word Ladder II 0.148 Hard
127 Word Ladder 0.200 Medium
128 Longest Consecutive Sequence 0.381 Hard
129 Sum Root to Leaf Numbers 0.376 Medium
130 Surrounded Regions 0.195 Medium
131 Palindrome Partitioning 0.354 Medium
132 Palindrome Partitioning II 0.248 Hard
133 Clone Graph 0.252 Medium
134 Gas Station 0.299 Medium
135 Candy 0.252 Hard
136 Single Number 0.553 Easy
137 Single Number II 0.426 Medium
138 Copy List with Random Pointer 0.259 Medium
139 Word Break 0.314 Medium
140 Word Break II 0.244 Hard
141 Linked List Cycle 0.351 Easy
142 Linked List Cycle II 0.307 Medium
143 Reorder List 0.267 Medium
144 Binary Tree Preorder Traversal 0.466 Medium
145 Binary Tree Postorder Traversal 0.419 Hard
146 LRU Cache 0.196 Hard
147 Insertion Sort List 0.338 Medium
148 Sort List 0.297 Medium
149 Max Points on a Line 0.152 Hard
150 Evaluate Reverse Polish Notation 0.283 Medium
151 Reverse Words in a String 0.156 Medium
152 Maximum Product Subarray 0.267 Medium
153 Find Minimum in Rotated Sorted Array 0.407 Medium
154 Find Minimum in Rotated Sorted Array II 0.378 Hard
155 Min Stack 0.309 Easy
156 Binary Tree Upside Down 0.458 Medium
157 Read N Characters Given Read4 0.290 Easy
158 Read N Characters Given Read4 II - Call multiple times 0.248 Hard
159 Longest Substring with At Most Two Distinct Characters 0.427 Hard
160 Intersection of Two Linked Lists 0.309 Easy
161 One Edit Distance 0.317 Medium
162 Find Peak Element 0.388 Medium
163 Missing Ranges 0.233 Medium
164 Maximum Gap 0.300 Hard
165 Compare Version Numbers 0.207 Medium
166 Fraction to Recurring Decimal 0.181 Medium
167 Two Sum II - Input array is sorted 0.473 Easy
168 Excel Sheet Column Title 0.272 Easy
169 Majority Element 0.479 Easy
170 Two Sum III - Data structure design 0.262 Easy
171 Excel Sheet Column Number 0.484 Easy
172 Factorial Trailing Zeroes 0.369 Easy
173 Binary Search Tree Iterator 0.434 Medium
174 Dungeon Game 0.241 Hard
179 Largest Number 0.234 Medium
186 Reverse Words in a String II 0.297 Medium
187 Repeated DNA Sequences 0.329 Medium
188 Best Time to Buy and Sell Stock IV 0.249 Hard
189 Rotate Array 0.252 Easy
190 Reverse Bits 0.294 Easy
191 Number of 1 Bits 0.403 Easy
198 House Robber 0.399 Easy
199 Binary Tree Right Side View 0.423 Medium
200 Number of Islands 0.364 Medium
201 Bitwise AND of Numbers Range 0.344 Medium
202 Happy Number 0.414 Easy
203 Remove Linked List Elements 0.333 Easy
204 Count Primes 0.265 Easy
205 Isomorphic Strings 0.346 Easy
206 Reverse Linked List 0.467 Easy
207 Course Schedule 0.336 Medium
208 Implement Trie (Prefix Tree) 0.306 Medium
209 Minimum Size Subarray Sum 0.320 Medium
210 Course Schedule II 0.300 Medium
211 Add and Search Word - Data structure design 0.251 Medium
212 Word Search II 0.246 Hard
213 House Robber II 0.346 Medium
214 Shortest Palindrome 0.251 Hard
215 Kth Largest Element in an Array 0.405 Medium
216 Combination Sum III 0.470 Medium
217 Contains Duplicate 0.469 Easy
218 The Skyline Problem 0.289 Hard
219 Contains Duplicate II 0.328 Easy
220 Contains Duplicate III 0.188 Medium
221 Maximal Square 0.302 Medium
222 Count Complete Tree Nodes 0.277 Medium
223 Rectangle Area 0.337 Medium
224 Basic Calculator 0.285 Hard
225 Implement Stack using Queues 0.342 Easy
226 Invert Binary Tree 0.531 Easy
227 Basic Calculator II 0.300 Medium
228 Summary Ranges 0.319 Medium
229 Majority Element II 0.291 Medium
230 Kth Smallest Element in a BST 0.452 Medium
231 Power of Two 0.407 Easy
232 Implement Queue using Stacks 0.380 Easy
233 Number of Digit One 0.290 Hard
234 Palindrome Linked List 0.334 Easy
235 Lowest Common Ancestor of a Binary Search Tree 0.397 Easy
236 Lowest Common Ancestor of a Binary Tree 0.300 Medium
237 Delete Node in a Linked List 0.472 Easy
238 Product of Array Except Self 0.503 Medium
239 Sliding Window Maximum 0.341 Hard
240 Search a 2D Matrix II 0.391 Medium
241 Different Ways to Add Parentheses 0.459 Medium
242 Valid Anagram 0.474 Easy
243 Shortest Word Distance 0.534 Easy
244 Shortest Word Distance II 0.410 Medium
245 Shortest Word Distance III 0.512 Medium
246 Strobogrammatic Number 0.403 Easy
247 Strobogrammatic Number II 0.409 Medium
248 Strobogrammatic Number III 0.327 Hard
249 Group Shifted Strings 0.440 Medium
250 Count Univalue Subtrees 0.438 Medium
251 Flatten 2D Vector 0.413 Medium
252 Meeting Rooms 0.488 Easy
253 Meeting Rooms II 0.394 Medium
254 Factor Combinations 0.439 Medium
255 Verify Preorder Sequence in Binary Search Tree 0.409 Medium
256 Paint House 0.462 Easy
257 Binary Tree Paths 0.410 Easy
258 Add Digits 0.518 Easy
259 3Sum Smaller 0.420 Medium
260 Single Number III 0.530 Medium
261 Graph Valid Tree 0.384 Medium
263 Ugly Number 0.396 Easy
264 Ugly Number II 0.333 Medium
265 Paint House II 0.384 Hard
266 Palindrome Permutation 0.581 Easy
267 Palindrome Permutation II 0.321 Medium
268 Missing Number 0.449 Easy
269 Alien Dictionary 0.261 Hard
270 Closest Binary Search Tree Value 0.406 Easy
271 Encode and Decode Strings 0.260 Medium
272 Closest Binary Search Tree Value II 0.399 Hard
273 Integer to English Words 0.227 Hard
274 H-Index 0.337 Medium
275 H-Index II 0.349 Medium
276 Paint Fence 0.349 Easy
277 Find the Celebrity 0.356 Medium
278 First Bad Version 0.260 Easy
279 Perfect Squares 0.377 Medium
280 Wiggle Sort 0.585 Medium
281 Zigzag Iterator 0.524 Medium
282 Expression Add Operators 0.306 Hard
283 Move Zeroes 0.514 Easy
284 Peeking Iterator 0.356 Medium
285 Inorder Successor in BST 0.357 Medium
286 Walls and Gates 0.453 Medium
287 Find the Duplicate Number 0.442 Medium
288 Unique Word Abbreviation 0.178 Medium
289 Game of Life 0.373 Medium
290 Word Pattern 0.334 Easy
291 Word Pattern II 0.385 Hard
292 Nim Game 0.554 Easy
293 Flip Game 0.571 Easy
294 Flip Game II 0.469 Medium
295 Find Median from Data Stream 0.292 Hard
296 Best Meeting Point 0.524 Hard
297 Serialize and Deserialize Binary Tree 0.348 Hard
298 Binary Tree Longest Consecutive Sequence 0.417 Medium
299 Bulls and Cows 0.358 Medium
300 Longest Increasing Subsequence 0.389 Medium
301 Remove Invalid Parentheses 0.359 Hard
302 Smallest Rectangle Enclosing Black Pixels 0.466 Hard
303 Range Sum Query - Immutable 0.319 Easy
304 Range Sum Query 2D - Immutable 0.270 Medium
305 Number of Islands II 0.396 Hard
306 Additive Number 0.277 Medium
307 Range Sum Query - Mutable 0.223 Medium
308 Range Sum Query 2D - Mutable 0.256 Hard
309 Best Time to Buy and Sell Stock with Cooldown 0.419 Medium
310 Minimum Height Trees 0.290 Medium
311 Sparse Matrix Multiplication 0.524 Medium
312 Burst Balloons 0.437 Hard
313 Super Ugly Number 0.383 Medium
314 Binary Tree Vertical Order Traversal 0.379 Medium
315 Count of Smaller Numbers After Self 0.350 Hard
316 Remove Duplicate Letters 0.303 Hard
317 Shortest Distance from All Buildings 0.348 Hard
318 Maximum Product of Word Lengths 0.455 Medium
319 Bulb Switcher 0.430 Medium
320 Generalized Abbreviation 0.462 Medium
321 Create Maximum Number 0.248 Hard
322 Coin Change 0.266 Medium
323 Number of Connected Components in an Undirected Graph 0.488 Medium
324 Wiggle Sort II 0.264 Medium
325 Maximum Size Subarray Sum Equals k 0.432 Medium
326 Power of Three 0.407 Easy
327 Count of Range Sum 0.306 Hard
328 Odd Even Linked List 0.446 Medium
329 Longest Increasing Path in a Matrix 0.374 Hard
330 Patching Array 0.326 Hard
331 Verify Preorder Serialization of a Binary Tree 0.370 Medium
332 Reconstruct Itinerary 0.298 Medium
333 Largest BST Subtree 0.310 Medium
334 Increasing Triplet Subsequence 0.398 Medium
335 Self Crossing 0.261 Hard
336 Palindrome Pairs 0.271 Hard
337 House Robber III 0.446 Medium
338 Counting Bits 0.621 Medium
339 Nested List Weight Sum 0.637 Easy
340 Longest Substring with At Most K Distinct Characters 0.388 Hard
341 Flatten Nested List Iterator 0.431 Medium
342 Power of Four 0.390 Easy
343 Integer Break 0.465 Medium
344 Reverse String 0.602 Easy
345 Reverse Vowels of a String 0.391 Easy
346 Moving Average from Data Stream 0.601 Easy
347 Top K Frequent Elements 0.495 Medium
348 Design Tic-Tac-Toe 0.460 Medium
349 Intersection of Two Arrays 0.481 Easy
350 Intersection of Two Arrays II 0.445 Easy
351 Android Unlock Patterns 0.446 Medium
352 Data Stream as Disjoint Intervals 0.409 Hard
353 Design Snake Game 0.272 Medium
354 Russian Doll Envelopes 0.325 Hard
355 Design Twitter 0.258 Medium
356 Line Reflection 0.303 Medium
357 Count Numbers with Unique Digits 0.461 Medium
358 Rearrange String k Distance Apart 0.317 Hard
359 Logger Rate Limiter 0.606 Easy
360 Sort Transformed Array 0.449 Medium
361 Bomb Enemy 0.401 Medium
362 Design Hit Counter 0.552 Medium
363 Max Sum of Rectangle No Larger Than K 0.337 Hard
364 Nested List Weight Sum II 0.539 Medium
365 Water and Jug Problem 0.280 Medium
366 Find Leaves of Binary Tree 0.611 Medium
367 Valid Perfect Square 0.386 Easy
368 Largest Divisible Subset 0.339 Medium
369 Plus One Linked List 0.551 Medium
370 Range Addition 0.571 Medium
371 Sum of Two Integers 0.509 Easy
372 Super Pow 0.346 Medium
373 Find K Pairs with Smallest Sums 0.312 Medium
374 Guess Number Higher or Lower 0.365 Easy
375 Guess Number Higher or Lower II 0.361 Medium
376 Wiggle Subsequence 0.361 Medium
377 Combination Sum IV 0.427 Medium
378 Kth Smallest Element in a Sorted Matrix 0.455 Medium
379 Design Phone Directory 0.358 Medium
380 Insert Delete GetRandom O(1) 0.399 Medium
381 Insert Delete GetRandom O(1) - Duplicates allowed 0.295 Hard
382 Linked List Random Node 0.475 Medium
383 Ransom Note 0.477 Easy
384 Shuffle an Array 0.473 Medium
385 Mini Parser 0.309 Medium
386 Lexicographical Numbers 0.422 Medium
387 First Unique Character in a String 0.472 Easy
388 Longest Absolute File Path 0.372 Medium
389 Find the Difference 0.512 Easy
390 Elimination Game 0.427 Medium
391 Perfect Rectangle 0.274 Hard
392 Is Subsequence 0.447 Medium
393 UTF-8 Validation 0.347 Medium
394 Decode String 0.421 Medium
395 Longest Substring with At Least K Repeating Characters 0.358 Medium
396 Rotate Function 0.338 Medium
397 Integer Replacement 0.305 Medium
398 Random Pick Index 0.446 Medium
399 Evaluate Division 0.423 Medium
400 Nth Digit 0.302 Easy
401 Binary Watch 0.448 Easy
402 Remove K Digits 0.260 Medium
403 Frog Jump 0.325 Hard
404 Sum of Left Leaves 0.475 Easy
405 Convert a Number to Hexadecimal 0.411 Easy
406 Queue Reconstruction by Height 0.566 Medium
407 Trapping Rain Water II 0.379 Hard
408 Valid Word Abbreviation 0.283 Easy
409 Longest Palindrome 0.458 Easy
410 Split Array Largest Sum 0.393 Hard
411 Minimum Unique Word Abbreviation 0.337 Hard
412 Fizz Buzz 0.581 Easy
413 Arithmetic Slices 0.546 Medium
414 Third Maximum Number 0.280 Easy
415 Add Strings 0.417 Easy
416 Partition Equal Subset Sum 0.389 Medium
417 Pacific Atlantic Water Flow 0.346 Medium
418 Sentence Screen Fitting 0.281 Medium
419 Battleships in a Board 0.629 Medium
420 Strong Password Checker 0.200 Hard
421 Maximum XOR of Two Numbers in an Array 0.479 Medium
422 Valid Word Square 0.365 Easy
423 Reconstruct Original Digits from English 0.446 Medium
424 Longest Repeating Character Replacement 0.427 Medium
425 Word Squares 0.431 Hard
432 All O`one Data Structure 0.279 Hard
434 Number of Segments in a String 0.367 Easy
435 Non-overlapping Intervals 0.413 Medium
436 Find Right Interval 0.415 Medium
437 Path Sum III 0.401 Easy
438 Find All Anagrams in a String 0.339 Easy
439 Ternary Expression Parser 0.513 Medium
440 K-th Smallest in Lexicographical Order 0.256 Hard
441 Arranging Coins 0.363 Easy
442 Find All Duplicates in an Array 0.567 Medium
443 String Compression 0.363 Easy
444 Sequence Reconstruction 0.196 Medium
445 Add Two Numbers II 0.462 Medium
446 Arithmetic Slices II - Subsequence 0.280 Hard
447 Number of Boomerangs 0.465 Easy
448 Find All Numbers Disappeared in an Array 0.512 Easy
449 Serialize and Deserialize BST 0.429 Medium
450 Delete Node in a BST 0.376 Medium
451 Sort Characters By Frequency 0.517 Medium
452 Minimum Number of Arrows to Burst Balloons 0.445 Medium
453 Minimum Moves to Equal Array Elements 0.480 Easy
454 4Sum II 0.477 Medium
455 Assign Cookies 0.472 Easy
456 132 Pattern 0.280 Medium
459 Repeated Substring Pattern 0.381 Easy
460 LFU Cache 0.250 Hard
461 Hamming Distance 0.696 Easy
462 Minimum Moves to Equal Array Elements II 0.519 Medium
463 Island Perimeter 0.578 Easy
464 Can I Win 0.252 Medium
465 Optimal Account Balancing 0.390 Hard
466 Count The Repetitions 0.273 Hard
467 Unique Substrings in Wraparound String 0.332 Medium
468 Validate IP Address 0.206 Medium
469 Convex Polygon 0.342 Medium
471 Encode String with Shortest Length 0.431 Hard
472 Concatenated Words 0.308 Hard
473 Matchsticks to Square 0.354 Medium
474 Ones and Zeroes 0.389 Medium
475 Heaters 0.297 Easy
476 Number Complement 0.610 Easy
477 Total Hamming Distance 0.477 Medium
479 Largest Palindrome Product 0.254 Easy
480 Sliding Window Median 0.307 Hard
481 Magical String 0.458 Medium
482 License Key Formatting 0.398 Easy
483 Smallest Good Base 0.336 Hard
484 Find Permutation 0.552 Medium
485 Max Consecutive Ones 0.538 Easy
486 Predict the Winner 0.452 Medium
487 Max Consecutive Ones II 0.459 Medium
488 Zuma Game 0.370 Hard
490 The Maze 0.434 Medium
491 Increasing Subsequences 0.388 Medium
492 Construct the Rectangle 0.480 Easy
493 Reverse Pairs 0.209 Hard
494 Target Sum 0.438 Medium
495 Teemo Attacking 0.515 Medium
496 Next Greater Element I 0.565 Easy
498 Diagonal Traverse 0.463 Medium
499 The Maze III 0.338 Hard
500 Keyboard Row 0.598 Easy
501 Find Mode in Binary Search Tree 0.376 Easy
502 IPO 0.365 Hard
503 Next Greater Element II 0.480 Medium
504 Base 7 0.440 Easy
505 The Maze II 0.387 Medium
506 Relative Ranks 0.468 Easy
507 Perfect Number 0.326 Easy
508 Most Frequent Subtree Sum 0.523 Medium
513 Find Bottom Left Tree Value 0.560 Medium
514 Freedom Trail 0.391 Hard
515 Find Largest Value in Each Tree Row 0.553 Medium
516 Longest Palindromic Subsequence 0.428 Medium
517 Super Washing Machines 0.363 Hard
520 Detect Capital 0.519 Easy
521 Longest Uncommon Subsequence I 0.557 Easy
522 Longest Uncommon Subsequence II 0.320 Medium
523 Continuous Subarray Sum 0.233 Medium
524 Longest Word in Dictionary through Deleting 0.432 Medium
525 Contiguous Array 0.414 Medium
526 Beautiful Arrangement 0.533 Medium
527 Word Abbreviation 0.441 Hard
529 Minesweeper 0.494 Medium
530 Minimum Absolute Difference in BST 0.472 Easy
531 Lonely Pixel I 0.563 Medium
532 K-diff Pairs in an Array 0.282 Easy
533 Lonely Pixel II 0.450 Medium
535 Encode and Decode TinyURL 0.739 Medium
536 Construct Binary Tree from String 0.425 Medium
537 Complex Number Multiplication 0.637 Medium
538 Convert BST to Greater Tree 0.489 Easy
539 Minimum Time Difference 0.460 Medium
540 Single Element in a Sorted Array 0.559 Medium
541 Reverse String II 0.438 Easy
542 01 Matrix 0.329 Medium
543 Diameter of Binary Tree 0.450 Easy
544 Output Contest Matches 0.717 Medium
545 Boundary of Binary Tree 0.325 Medium
546 Remove Boxes 0.350 Hard
547 Friend Circles 0.491 Medium
548 Split Array with Equal Sum 0.377 Medium
549 Binary Tree Longest Consecutive Sequence II 0.429 Medium
551 Student Attendance Record I 0.445 Easy
552 Student Attendance Record II 0.315 Hard
553 Optimal Division 0.552 Medium
554 Brick Wall 0.463 Medium
555 Split Concatenated Strings 0.380 Medium
556 Next Greater Element III 0.290 Medium
557 Reverse Words in a String III 0.601 Easy
560 Subarray Sum Equals K 0.402 Medium
561 Array Partition I 0.664 Easy
562 Longest Line of Consecutive One in Matrix 0.413 Medium
563 Binary Tree Tilt 0.472 Easy
564 Find the Closest Palindrome 0.175 Hard
565 Array Nesting 0.494 Medium
566 Reshape the Matrix 0.579 Easy
567 Permutation in String 0.363 Medium
568 Maximum Vacation Days 0.374 Hard
572 Subtree of Another Tree 0.402 Easy
573 Squirrel Simulation 0.523 Medium
575 Distribute Candies 0.580 Easy
576 Out of Boundary Paths 0.306 Medium
581 Shortest Unsorted Continuous Subarray 0.291 Easy
582 Kill Process 0.506 Medium
583 Delete Operation for Two Strings 0.446 Medium
587 Erect the Fence 0.333 Hard
588 Design In-Memory File System 0.361 Hard
591 Tag Validator 0.309 Hard
592 Fraction Addition and Subtraction 0.461 Medium
593 Valid Square 0.398 Medium
594 Longest Harmonious Subsequence 0.411 Easy
598 Range Addition II 0.481 Easy
599 Minimum Index Sum of Two Lists 0.464 Easy
600 Non-negative Integers without Consecutive Ones 0.317 Hard
604 Design Compressed String Iterator 0.331 Easy
605 Can Place Flowers 0.301 Easy
606 Construct String from Binary Tree 0.497 Easy
609 Find Duplicate File in System 0.522 Medium
611 Valid Triangle Number 0.420 Medium
616 Add Bold Tag in String 0.381 Medium
617 Merge Two Binary Trees 0.673 Easy
621 Task Scheduler 0.425 Medium
623 Add One Row to Tree 0.461 Medium
624 Maximum Distance in Arrays 0.351 Easy
625 Minimum Factorization 0.312 Medium
628 Maximum Product of Three Numbers 0.446 Easy
629 K Inverse Pairs Array 0.270 Hard
630 Course Schedule III 0.292 Hard
631 Design Excel Sum Formula 0.279 Hard
632 Smallest Range 0.421 Hard
633 Sum of Square Numbers 0.323 Easy
634 Find the Derangement of An Array 0.356 Medium
635 Design Log Storage System 0.494 Medium
636 Exclusive Time of Functions 0.446 Medium
637 Average of Levels in Binary Tree 0.557 Easy
638 Shopping Offers 0.448 Medium
639 Decode Ways II 0.245 Hard
640 Solve the Equation 0.387 Medium
642 Design Search Autocomplete System 0.310 Hard
643 Maximum Average Subarray I 0.375 Easy
644 Maximum Average Subarray II 0.246 Hard
645 Set Mismatch 0.397 Easy
646 Maximum Length of Pair Chain 0.474 Medium
647 Palindromic Substrings 0.550 Medium
648 Replace Words 0.476 Medium
649 Dota2 Senate 0.365 Medium
650 2 Keys Keyboard 0.449 Medium
651 4 Keys Keyboard 0.496 Medium
652 Find Duplicate Subtrees 0.372 Medium
653 Two Sum IV - Input is a BST 0.500 Easy
654 Maximum Binary Tree 0.697 Medium
655 Print Binary Tree 0.494 Medium
656 Coin Path 0.257 Hard
657 Judge Route Circle 0.684 Easy
658 Find K Closest Elements 0.352 Medium
659 Split Array into Consecutive Subsequences 0.369 Medium
660 Remove 9 0.493 Hard
661 Image Smoother 0.461 Easy
662 Maximum Width of Binary Tree 0.379 Medium
663 Equal Tree Partition 0.366 Medium
664 Strange Printer 0.337 Hard
665 Non-decreasing Array 0.203 Easy
666 Path Sum IV 0.503 Medium
667 Beautiful Arrangement II 0.515 Medium
668 Kth Smallest Number in Multiplication Table 0.398 Hard
669 Trim a Binary Search Tree 0.582 Easy
670 Maximum Swap 0.385 Medium
671 Second Minimum Node In a Binary Tree 0.418 Easy
672 Bulb Switcher II 0.493 Medium
673 Number of Longest Increasing Subsequence 0.316 Medium
674 Longest Continuous Increasing Subsequence 0.423 Easy
675 Cut Off Trees for Golf Event 0.269 Hard
676 Implement Magic Dictionary 0.494 Medium
677 Map Sum Pairs 0.518 Medium
678 Valid Parenthesis String 0.293 Medium
679 24 Game 0.385 Hard
680 Valid Palindrome II 0.323 Easy
681 Next Closest Time 0.421 Medium
682 Baseball Game 0.579 Easy
683 K Empty Slots 0.349 Hard
684 Redundant Connection 0.432 Medium
685 Redundant Connection II 0.279 Hard
686 Repeated String Match 0.326 Easy
687 Longest Univalue Path 0.330 Easy
688 Knight Probability in Chessboard 0.395 Medium
689 Maximum Sum of 3 Non-Overlapping Subarrays 0.409 Hard
690 Employee Importance 0.517 Easy
691 Stickers to Spell Word 0.347 Hard
692 Top K Frequent Words 0.412 Medium
693 Binary Number with Alternating Bits 0.557 Easy
694 Number of Distinct Islands 0.450 Medium
695 Max Area of Island 0.517 Easy
696 Count Binary Substrings 0.506 Easy
697 Degree of an Array 0.468 Easy
698 Partition to K Equal Sum Subsets 0.375 Medium
699 Falling Squares 0.367 Hard
711 Number of Distinct Islands II 0.416 Hard
712 Minimum ASCII Delete Sum for Two Strings 0.512 Medium
713 Subarray Product Less Than K 0.330 Medium
714 Best Time to Buy and Sell Stock with Transaction Fee 0.451 Medium
715 Range Module 0.318 Hard
716 Max Stack 0.370 Hard
717 1-bit and 2-bit Characters 0.495 Easy
718 Maximum Length of Repeated Subarray 0.410 Medium
719 Find K-th Smallest Pair Distance 0.271 Hard
720 Longest Word in Dictionary 0.413 Easy
721 Accounts Merge 0.325 Medium
722 Remove Comments 0.279 Medium
723 Candy Crush 0.552 Medium
724 Find Pivot Index 0.395 Easy
725 Split Linked List in Parts 0.474 Medium
726 Number of Atoms 0.442 Hard
727 Minimum Window Subsequence 0.311 Hard
728 Self Dividing Numbers 0.667 Easy
729 My Calendar I 0.422 Medium
730 Count Different Palindromic Subsequences 0.352 Hard
731 My Calendar II 0.373 Medium
732 My Calendar III 0.510 Hard
733 Flood Fill 0.478 Easy
734 Sentence Similarity 0.386 Easy
735 Asteroid Collision 0.372 Medium
736 Parse Lisp Expression 0.431 Hard
737 Sentence Similarity II 0.409 Medium
738 Monotone Increasing Digits 0.413 Medium
739 Daily Temperatures 0.527 Medium
740 Delete and Earn 0.437 Medium
741 Cherry Pickup 0.231 Hard
742 Closest Leaf in a Binary Tree 0.334 Medium
743 Network Delay Time 0.342 Medium
744 Find Smallest Letter Greater Than Target 0.444 Easy
745 Prefix and Suffix Search 0.248 Hard
746 Min Cost Climbing Stairs 0.433 Easy
747 Largest Number At Least Twice of Others 0.417 Easy
748 Shortest Completing Word 0.525 Medium
749 Contain Virus 0.388 Hard
750 Number Of Corner Rectangles 0.526 Medium
751 IP to CIDR 0.548 Easy
752 Open the Lock 0.380 Medium
753 Cracking the Safe 0.396 Hard
754 Reach a Number 0.259 Medium
755 Pour Water 0.337 Medium
756 Pyramid Transition Matrix 0.451 Medium
757 Set Intersection Size At Least Two 0.343 Hard
758 Bold Words in String 0.371 Easy
759 Employee Free Time 0.517 Hard
760 Find Anagram Mappings 0.753 Easy
761 Special Binary String 0.400 Hard
762 Prime Number of Set Bits in Binary Representation 0.548 Easy
763 Partition Labels 0.641 Medium
764 Largest Plus Sign 0.362 Medium
765 Couples Holding Hands 0.479 Hard
766 Toeplitz Matrix 0.578 Easy
767 Reorganize String 0.355 Medium
768 Max Chunks To Make Sorted II 0.421 Hard
769 Max Chunks To Make Sorted 0.473 Medium
770 Basic Calculator IV 0.427 Hard
771 Jewels and Stones 0.824 Easy
772 Basic Calculator III 0.375 Hard
773 Sliding Puzzle 0.470 Hard
774 Minimize Max Distance to Gas Station 0.290 Hard
775 Global and Local Inversions 0.310 Medium
776 Split BST 0.485 Medium
777 Swap Adjacent in LR String 0.262 Medium
778 Swim in Rising Water 0.440 Hard
779 K-th Symbol in Grammar 0.352 Medium
780 Reaching Points 0.211 Hard
781 Rabbits in Forest 0.487 Medium
782 Transform to Chessboard 0.345 Hard
783 Minimum Distance Between BST Nodes 0.471 Easy
784 Letter Case Permutation 0.515 Easy
785 Is Graph Bipartite? 0.384 Medium
786 K-th Smallest Prime Fraction 0.284 Hard
787 Cheapest Flights Within K Stops 0.310 Medium
788 Rotated Digits 0.510 Easy
789 Escape The Ghosts 0.452 Medium
790 Domino and Tromino Tiling 0.315 Medium
791 Custom Sort String 0.614 Medium
792 Number of Matching Subsequences 0.335 Medium
793 Preimage Size of Factorial Zeroes Function 0.485 Hard
794 Valid Tic-Tac-Toe State 0.270 Medium
795 Number of Subarrays with Bounded Maximum 0.387 Medium
796 Rotate String 0.677 Easy
797 All Paths From Source to Target 0.687 Medium
798 Smallest Rotation with Highest Score    New 0.285 Hard
799 Champagne Tower    New 0.272 Medium

LeetCode All in One题解汇总(持续更新中...)

本文版权归作者AlvinZH和博客园所有,欢迎转载和商用,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.