LeetCode Algorithms' Solutions


Talk is cheap, show me the code!
Linus Torvalds

  • 如果题解中有谬误或疑问的地方,欢迎大家留言交流!
# Title Acceptance Difficulty
1 Two Sum 40.2%

1

Easy
2 Add Two Numbers 30.4%

2

Medium
7 Reverse Integer 25.1%

1

Easy
8 String to Integer (atoi) 14.4%

2

Medium
9 Palindrome Number 41.5%

1

Easy
13 Roman to Integer 51.3%

1

Easy
20 Valid Parentheses 35.7%

1

Easy
21 Merge Two Sorted Lists 45.4%

1

Easy
27 Remove Element 43.3%

1

Easy
28 Implement strStr() 31.0%

1

Easy
35 Search Insert Position 40.4%

1

Easy
38 Count and Say 39.2%

1

Easy
50 Pow(x, n) 27.4%

2

Medium
53 Maximum Subarray 42.5%

1

Easy
69 Sqrt(x) 30.4%

1

Easy
70 Climbing Stairs 43.1%

1

Easy
83 Remove Duplicates from Sorted List 41.7%

1

Easy
84 Largest Rectangle in Histogram 30.0%

3

Hard
100 Same Tree 49.2%

1

Easy
101 Symmetric Tree 42.5%

1

Easy
102 Binary Tree Level Order Traversal 46.6%

2

Medium
104 Maximum Depth of Binary Tree 58.8%

1

Easy
107 Binary Tree Level Order Traversal II 45.3%

1

Easy
108 Convert Sorted Array to Binary Search Tree 48.8%

1

Easy
112 Path Sum 36.8%

1

Easy
118 Pascal’s Triangle 44.1%

1

Easy
119 Pascal’s Triangle II 41.6%

1

Easy
121 Best Time to Buy and Sell Stock 45.9%

1

Easy
122 Best Time to Buy and Sell Stock II 50.6%

1

Easy
125 Valid Palindrome 29.9%

1

Easy
136 Single Number 58.6%

1

Easy
153 Find Minimum in Rotated Sorted Array 42.3%

2

Medium
154 Find Minimum in Rotated Sorted Array II 38.8%

3

Hard
155 Min Stack 35.2%

1

Easy
167 Two Sum II - Input array is sorted 48.9%

1

Easy
168 Excel Sheet Column Title 28.4%

1

Easy
169 Majority Element 51.2%

1

Easy
171 Excel Sheet Column Number 50.7%

1

Easy
172 Factorial Trailing Zeroes 37.2%

1

Easy
189 Rotate Array 28.6%

1

Easy
190 Reverse Bits 29.9%

1

Easy
191 Number of 1 Bits 41.7%

1

Easy
202 Happy Number 44.1%

1

Easy
204 Count Primes 28.0%

1

Easy
206 Reverse Linked List 52.2%

1

Easy
217 Contains Duplicate 50.5%

1

Easy
226 Invert Binary Tree 56.7%

1

Easy
231 Power of Two 41.6%

1

Easy
237 Delete Node in a Linked List 51.6%

1

Easy
242 Valid Anagram 50.6%

1

Easy
258 Add Digits 53.4%

1

Easy
263 Ugly Number 40.3%

1

Easy
264 Ugly Number II 35.4%

2

Medium
268 Missing Number 47.3%

1

Easy
278 First Bad Version 28.6%

1

Easy
283 Move Zeroes 53.4%

1

Easy
292 Nim Game 55.4%

1

Easy
303 Range Sum Query - Immutable 36.2%

1

Easy
307 Range Sum Query - Mutable 27.1%

2

Medium
326 Power of Three 41.3%

1

Easy
338 Counting Bits 63.8%

2

Medium
342 Power of Four 39.9%

1

Easy
344 Reverse String 62.6%

1

Easy
345 Reverse Vowels of a String 40.7%

1

Easy
349 Intersection of Two Arrays 52.4%

1

Easy
350 Intersection of Two Arrays II 46.5%

1

Easy
367 Valid Perfect Square 39.3%

1

Easy
371 Sum of Two Integers 51.4%

1

Easy
383 Ransom Note 49.1%

1

Easy
387 First Unique Character in a String 48.8%

1

Easy
389 Find the Difference 52.6%

1

Easy
401 Binary Watch 45.0%

1

Easy
404 Sum of Left Leaves 48.6%

1

Easy
405 Convert a Number to Hexadecimal 41.6%

1

Easy
409 Longest Palindrome 47.3%

1

Easy
412 Fizz Buzz 58.7%

1

Easy
413 Arithmetic Slices 55.1%

2

Medium
414 Third Maximum Number 28.6%

1

Easy
415 Add Strings 42.9%

1

Easy
419 Battleships in a Board 65.0%

2

Medium
437 Path Sum III 41.7%

1

Easy
442 Find All Duplicates in an Array 59.6%

2

Medium
447 Number of Boomerangs 48.9%

1

Easy
448 Find All Numbers Disappeared in an Array 52.5%

1

Easy
451 Sort Characters By Frequency 54.6%

2

Medium
453 Minimum Moves to Equal Array Elements 48.9%

1

Easy
455 Assign Cookies 48.0%

1

Easy
459 Repeated Substring Pattern 39.2%

1

Easy
461 Hamming Distance 69.9%

1

Easy
463 Island Perimeter 60.0%

1

Easy
476 Number Complement 62.0%

1

Easy
479 Largest Palindrome Product 27.0%

3

Hard
485 Max Consecutive Ones 54.4%

1

Easy
492 Construct the Rectangle 48.3%

1

Easy
496 Next Greater Element I 58.4%

1

Easy
500 Keyboard Row 61.5%

1

Easy
501 Find Mode in Binary Search Tree 38.8%

1

Easy
504 Base 7 44.5%

1

Easy
506 Relative Ranks 47.8%

1

Easy
513 Find Bottom Left Tree Value 57.8%

2

Medium
520 Detect Capital 52.2%

1

Easy
530 Minimum Absolute Difference in BST 49.5%

1

Easy
541 Reverse String II 44.9%

1

Easy
543 Diameter of Binary Tree 46.1%

1

Easy
557 Reverse Words in a String III 62.9%

1

Easy
561 Array Partition I 68.1%

1

Easy
563 Binary Tree Tilt 46.8%

1

Easy
566 Reshape the Matrix 58.3%

1

Easy
575 Distribute Candies 59.0%

1

Easy
599 Minimum Index Sum of Two Lists 47.0%

1

Easy
606 Construct String from Binary Tree 50.9%

1

Easy
617 Merge Two Binary Trees 68.9%

1

Easy
637 Average of Levels in Binary Tree 57.7%

1

Easy
654 Maximum Binary Tree 71.7%

2

Medium
657 Robot Return to Origin 70.5%

1

Easy
661 Image Smoother 47.7%

1

Easy
665 Non-decreasing Array 19.6%

1

Easy
669 Trim a Binary Search Tree 59.6%

1

Easy
671 Second Minimum Node In a Binary Tree 43.2%

1

Easy