Skip to content

WilliamZhaoz/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Up to date (2018-7-8), there are 833 Algorithms questions on LeetCode Online Judge.
The number of questions is increasing continually.
Here are the Solutions of some of these questions.
I'll keep updating for full summary and better Solution & Analysis. Stay tuned for updates.

Title Bug free Difficulty Tags Solution & Analysis & Note
1.Two Sum 3/24/2018 Easy Array Hash Table c++
4.Median of Two Sorted Arrays 9/7/2018 ★☆☆ Hard Array Binary Search Divided and Conquer c++
11.Container With Most Water 6/3/2018 Medium Array Two Pointers c++
16.3Sum Closest 3/26/2018 Medium Array Two Pointers c++
17.Letter Combinations of a Phone Number 7/21/2018 Medium String Backtracking c++
18.4Sum 5/23/2018 Medium Array Hash Table Two Pointers c++
19. Remove Nth Node From End of List 7/14/2018 Medium Link List Two Pointers c++
20. Valid Parentheses 7/22/2018 Easy String Stack c++
21. Merge Two Sorted Lists 10/7/2018 ★★★ Easy Link List c++
22. Generate Parentheses 9/7/2018 ★★☆ Medium Backtracking String c++
26.Remove Duplicates from Sorted Array 7/10/2018 Easy Array c++
28.Implement strStr() 6/8/2018 Easy Two Pointers string c++
29.Divide Two Integers ★☆☆ Medium Math Binary Search c++
33.Search in Rotated Sorted Array 8/23/2018 Medium Array Binary Search c++
31.Next Permutation ★☆☆ Medium Array c++
34.Find First and Last Position of Element in Sorted Array 8/29/2018 Medium Array Binary Search c++
35.Search Insert Position 4/4/2018 Easy Array Binary Search c++
36. Valid Sudoku 7/30/2018 Medium Hash Table c++
37. Sudoku Solver 7/30/2018 Hard Hash Table Backtracking c++
38.Count and Say 8/8/2018 Easy String c++
39.Combination Sum 7/21/2018 Medium Array Backtracking c++
40.Combination Sum II 6/26/2018 Medium Array Backtracking c++
41.First Missing Positive 5/20/2018 ★☆☆ Hard Array c++
42.Trapping Rain Water 6/3/2018 ★☆☆ Hard Array Two Pointers stack c++
45.Jump Game II 5/3/2018 ★☆☆ Hard Array Greedy c++
46. Permutations 7/21/2018 Medium Backtracking c++
47. Permutations II 6/26/2018 ★☆☆ Medium Backtracking c++
48.Rotate Image 10/6/2018 Medium Array c++
49. Group Anagrams 8/8/2018 ★☆☆ Medium String Hash Table c++
50. Pow(x, n) ★☆☆ Medium Math Binary Search c++
52.N-Queens II 7/23/2018 ★☆☆ Hard Backtracking c++
53. Maximum Subarray 8/2/2018 Easy Array Devide and Conquer Dynamic Programming c++
54.Spiral Matrix 6/26/2018 Medium Array c++
55.Jump Game 5/2/2018 Medium Array Greedy c++
56.Merge Intervals 10/7/2018 ★☆☆ Medium Array Sort c++
57.Insert Interval ★☆☆ Medium Array Sort c++
59.Spiral Matrix II 6/2/2018 ★☆☆ Medium Array c++
60.Permutation Sequence 6/19/2018 ★☆☆ Medium Math Backtracking c++
61.Rotate List 7/15/2018 Medium Link List Two Points c++
62.Unique Paths 8/30/2018 Medium Array Dynamic Programming c++
63.Unique Paths II 8/30/2018 Medium Array Dynamic Programming c++
64. Minimum Path Sum ★★☆ Medium Array Dynamic Programming c++
66.Plus One ★★☆ Easy Array Math c++
69.Sqrt(x) 11/7/2018 Easy Math Binary Search c++
72.Edit Distance 5/3/2018 Hard String Dynamic Programming c++
73.Set Matrix Zeroes 10/6/2018 Medium Array c++
74.Search a 2D Matrix 8/30/2018 Medium Array Binary Search c++
75.Sort Colors 8/23/2018 Medium Sort Two Points Array c++
78. Subsets 6/12/2018 Medium Array Backtracking Bit Manipulation c++
79.Word Search 10/5/2018 ★☆☆ Medium Array Backtracking c++
80.Remove Duplicates from Sorted Array II ★☆☆ Medium Array Two Pointers c++
81. Search in Rotated Sorted Array II 9/6/2018 ★☆☆ Medium Array Binary Search c++
83. Remove Duplicates from Sorted List 7/14/2018 Easy Link List c++
88.Merge Sorted Array 9/6/2018 ★☆☆ Easy Array Two Pointers c++
90. Subsets II 7/14/2018 Medium Array Backtracking c++
92.Reverse Linked List II 7/14/2018 ★☆☆ Medium Linked List c++
93.Restore IP Addresses 6/28/2018 Medium String Backtracking c++
94.Binary Tree Inorder Traversal 5/17/1018 Medium Hash Table Stack Tree c++
98. Validate Binary Search Tree 10/6/2018 Medium Tree Depth-first Search c++
101.Symmetric Tree 10/6/2018 Easy Tree Depth-first Search Breadth-first Search c++
102. Binary Tree Level Order Traversal 3/9/2018 Medium Tree Breadth-first Search c++
103. Binary Tree Zigzag Level Order Traversal 10/6/2018 Medium Tree Stack Breadth-first Search c++
104. Maximum Depth of Binary Tree 3/10/2018 Easy Tree Depth-first Search c++
105.Construct Binary Tree from Preorder and Inorder Traversal 8/5/2018 ★☆☆ Medium Array Depth-first Search Tree c++
106.Construct Binary Tree from Inorder and Postorder Traversal 10/6/2018 ★☆☆ Medium Array Depth-first Search Tree c++
107. Binary Tree Level Order Traversal II 3/9/2018 Easy Tree Breadth-first Search c++
110. Balanced Binary Tree 3/10/2018 ★☆☆ Easy Tree Depth-first Search c++
111. Minimum Depth of Binary Tree 5/21/2018 ★☆☆ Easy Tree Depth-first Search Breadth-first Search c++
112. Path Sum 10/6/2018 Easy Tree Depth-first Search c++
118. Pascal's Triangle 7/9/2018 Easy Array c++
119.Pascal's Triangle II ★★☆ Easy Array c++
120.Triangle 9/6/2018 ★☆☆ Medium Array Dynamic Programming c++
121. Best Time to Buy and Sell Stock 7/8/2018 Easy Array Dynamic Programming c++
122. Best Time to Buy and Sell Stock II 7/20/2018 Easy Array Greedy c++
123. Best Time to Buy and Sell Stock III 8/3/2018 Hard Array Dynamic Processing c++
124. Binary Tree Maximum Path Sum 10/6/2018 ★☆☆ Hard Tree Depth-first Search c++
127. Remove Element 7/9/2018 Easy Array Two Pointers c++
129. Sum Root to Leaf Numbers 3/21/2018 Medium Tree Depth-first Search c++
131. Palindrome Partitioning 6/28/2018 Medium Backtracking c++
132. Palindrome Partitioning II 9/2/2018 ★☆☆ Hard Dynamic Programing c++
133. Clone Graph × Medium Depth-first Search Breadth-first Search Graph c++
138. Copy List with Random Pointer 7/27/2018 Medium Link List Hash Table c++
141. Linked List Cycle 9/4/2018 Easy Link List Two Point c++
142. Linked List Cycle II 9/4/2018 Medium Link List Two Point c++
143. Reorder List 9/4/2018 Medium Link List c++
144.Binary Tree Preorder Traversal 5/17/2018 Medium Stack Tree c++
145.Binary Tree Postorder Traversal 5/20/2018 Hard Stack Tree c++
146.LRU Cache 7/29/2018 ★★★ Hard Design c++
147.Insertion Sort List 7/16/2018 ★★☆ Medium Link List c++
148.Sort List 7/28/2016 ★★☆ Medium Link List Sort c++
151. Reverse Words in a String 8/8/2018 Medium String c++
153.Find Minimum in Rotated Sorted Array 9/4/2018 Medium Array Binary Search c++
154.Find Minimum in Rotated Sorted Array II 9/6/2018 ★☆☆ Hard Array Binary Search c++
160.Intersection of Two Linked Lists 7/16/2018 Easy Link List c++
161. One Edit Distance 8/13/2018 Medium String c++
162.Find Peak Element 9/5/2018 Medium Array Binary Search c++
165. Compare Version Numbers 11/7/2018 Medium String c++
167.Two Sum II - Input array is sorted 5/22/2018 Easy Array Two Pointers Binary-search Tree c++
169. Majority Element 9/5/2018 ★★☆ Easy Array Devide and Conquer Bit manipulation c++
174.Dungeon Game 9/6/2018 ★☆☆ Hard Binary-search Tree Dynamic Programming c++
186. Reverse Words in a String II 8/22/2018 Medium String c++
188.Best Time to Buy and Sell Stock IV 8/4/2018 Hard Dynamic Processing c++
189.Rotate Array 9/6/2018 Easy Array c++
198.House Robber 8/5/2018 Easy Dynamic Processing c++
206.Reverse Linked List 5/21/2018 Easy Linked List c++
209.Minimum Size Subarray Sum 9/6/2018 ★☆☆ Easy Array Two Point Binary Search c++
213.House Robber II 8/5/2018 Medium Dynamic Processing c++
216.Combination Sum III 6/20/2018 Medium Array Backtracking c++
217. Contains Duplicate 7/8/2018 Easy Array Hash Table c++
219.Contains Duplicate II 9/6/2018 Easy Array Hash Table c++
220. Contains Duplicate III 9/6/2018 ★☆☆ Medium Binary Search c++
222.Count Complete Tree Nodes 9/6/2018 ★★☆ Medium Binary Search Tree c++
229.Majority Element II 9/5/2018 ★☆☆ Medium Array c++
230.Kth Smallest Element in a BST 9/13/2018 ★★★ Medium Binary Search Tree c++
235.Lowest Common Ancestor of a Binary Search Tree 8/7/2018 ★☆☆ Easy Tree c++
236.Lowest Common Ancestor of a Binary Tree 10/6/2018 Medium Tree c++
238.Product of Array Except Self 6/3/2018 Medium Array c++
238. Product of Array Except Self 7/12/2018 Medium Array c++
240.Search a 2D Matrix II 9/13/2018 ★☆☆ Medium Binary Search Divide and Conquer c++
252.Meeting Rooms 9/14/2018 Easy Sort c++
253.Meeting Rooms II 9/19/2018 ★☆☆ Medium Sort Heap Greedy c++
266. Palindrome Permutation 8/13/2018 Easy Hash Table c++
268. Missing Number 9/19/2018 ★☆☆ Easy Array Math Bit manipulation c++
270. Closest Binary Search Tree Value 10/6/2018 Easy Tree Binary Search c++
272. Closest Binary Search Tree Value II 9/20/2018 Hard Tree Stack c++
274.H-Index 9/20/2018 Medium Hash Table Sort c++
275.H-Index II 9/21/2018 ★☆☆ Medium Binary Search c++
277. Find the Celebrity 9/21/2018 Medium Array c++
278.First Bad Version 9/21/2018 Easy Binary Search c++
283. Move Zeroes 9/21/2018 Easy Array Two Pointers c++
285. Inorder Successor in BST 10/6/2018 ★☆☆ Medium Tree c++
287.Find the Duplicate Number 9/21/2018 Medium Array Two Pointers Binary Search c++
300.Longest Increasing Subsequence 9/21/2018 ★☆☆ Medium Binary Search Dynamic Programming c++
301.Remove Invalid Parentheses /9/24/2018 ★☆☆ Medium Depth-first Search Breadth-first Search c++
309.Best Time to Buy and Sell Stock with Cooldown 9/24/2018 ★☆☆ Medium Dynamic Processing c++
339. Nested List Weight Sum 9/25/2018 Easy Depth-first Search c++
346. Moving Average from Data Stream 9/25/2018 Medium Design Queue c++
348.Design Tic-Tac-Toe 9/25/2018 Medium Design c++
349.Intersection of Two Arrays 8/28/2018 Easy Hash Table Two Pointers Binary Search Sort c++
350.Intersection of Two Arrays II 9/26/2018 Easy Hash Table Two Pointers Binary Search Sort c++
354.Russian Doll Envelopes 9/26/2018 Hard Binary Search Dynamic Programming c++
363.Max Sum of Rectangle No Larger Than K 10/2/2018 Hard Binary Search Dynamic Programming Queue c++
364. Nested List Weight Sum II 10/2/2018 Medium Depth-first Search c++
367.Valid Perfect Square 10/2/2018 Easy Math Binary Search c++
374.Guess Number Higher or Lower 10/2/2018 Easy Binary Search c++
377.Combination Sum IV 10/2/2018 ★☆☆ Medium Dynamic Programming c++
378.Kth Smallest Element in a Sorted Matrix 10/2/2018 ★☆☆ Medium Binary Search Heap c++
392.Is Subsequence 10/2/2018 ★☆☆ Medium Binary Search Dynamic Programming Greedy c++
407.Trapping Rain Water II Hard Array Breadth-first Search c++
410. Split Array Largest Sum 10/3/2018 ★☆☆ Hard Binary Search Dynamic Programming c++
414.Third Maximum Number 10/2/2018 ★★★ Easy Array c++
441. Arranging Coins 10/2/2018 ★☆☆ Easy Math Binary Search c++
436. Find Right Interval ignore Medium Binary Search c++
442. Find All Duplicates in an Array 10/3/2018 Medium Array c++
448. Find All Numbers Disappeared in an Array 10/3/2018 Easy Array c++
454.4Sum II 10/3/2018 Medium Hash Table Binary Search c++
473. Matchsticks to Square 10/3/2018 ★☆☆ Medium Depth-first Search c++
475.Heaters 10/3/2018 ★☆☆ Easy Binary Search c++
483.Smallest Good Base hard Binary Search c++
485. Max Consecutive Ones 10/3/2018 Easy Array c++
495. Teemo Attacking 10/3/2018 Medium Array c++
501. Find Mode in Binary Search Tree 10/3/2018 Easy Tree c++
532.K-diff Pairs in an Array 10/3/2018 ★☆☆ Easy Array Hash Table Two Pointers c++
543.Diameter of Binary Tree 8/8/2018 Easy Tree c++
560.Subarray Sum Equals K 10/3/2018 ★☆☆ Medium Array Hash Table c++
561. Array Partition I ★☆☆ Easy Array c++
565.Array Nesting 10/3/2018 ★☆☆ Medium Array c++
566. Reshape the Matrix ★☆☆ Easy Array c++
567. Permutation in String 10/4/2018 ★☆☆ Medium Two Pointers c++
581.Shortest Unsorted Continuous Subarray 10/4/2018 ★☆☆ Easy Array c++
605. Can Place Flowers 10/4/2018 Easy Array c++
611.Valid Triangle Number 10/4/2018 ★☆☆ Medium Array Binary Search Tow Pointers c++
621.Task Scheduler 10/4/2018 ★☆☆ Medium Array Queue Greedy c++
628.Maximum Product of Three Numbers 10/4/2018 ★☆☆ Easy Array c++
643.Maximum Average Subarray I 10/4/2018 Easy Array c++
653.Two Sum IV - Input is a BST 8/6/2018 Easy Tree c++
661. Image Smoother 10/3/2018 Easy Array c++
658. Find K Closest Elements 10/4/2018 ★☆☆ Medium Binary Search c++
665.Non-decreasing Array 10/4/2018 ★☆☆ Easy Array c++
667. Beautiful Arrangement II 10/4/2018 ★☆☆ Medium Array c++
668. Kth Smallest Number in Multiplication Table Hard Binary Search c++
674.Longest Continuous Increasing Subsequence 10/4/2018 Easy Array c++
681. Next Closest Time ignore Medium String c++
683. K Empty Slots ★☆☆ Hard Array Binary Search Tree c++
687. Longest Univalue Path 10/4/2018 ★☆☆ Easy Tree Recursion c++
695. Max Area of Island 10/4/2018 ★☆☆ Easy Array Depth-first search c++
697. Degree of an Array 10/4/2018 ★☆☆ Easy Array c++
713.Subarray Product Less Than K 10/4/2018 ★☆☆ Medium Array Two Points c++
714.Best Time to Buy and Sell Stock with Transaction Fee ★☆☆ Medium Array Greedy Dynamic Programming c++
717. 1-bit and 2-bit Characters 10/5/2018 ★☆☆ Easy Array c++
718. Maximum Length of Repeated Subarray 10/5/2018 ★☆☆ Medium Array Hash Table Binary Search Dynamic Programming c++
719. Find K-th Smallest Pair Distance Hard Array Binary Search Heap c++
724. Find Pivot Index 10/5/2018 ★☆☆ Easy Array c++
729.My Calendar I 10/5/2018 ★☆☆ Medium Array c++
744. Find Smallest Letter Greater Than Target 10/5/2018 Easy Binary Search c++
746. Min Cost Climbing Stairs 10/5/2018 Easy Array Dynamic Programming c++
747. Largest Number At Least Twice of Others 10/5/2018 Easy Array c++
766. Toeplitz Matrix 10/5/2018 Easy Array c++
769. Max Chunks To Make Sorted 10/5/2018 ★☆☆ Medium Array c++
775.Global and Local Inversions 10/5/2018 ★☆☆ Medium Array Math c++
778. Swim in Rising Water Hard Binary Search Heap Depth-first Search Union Find c++
786. K-th Smallest Prime Fraction Hard Binary Search Heap c++
792.Number of Matching Subsequences 10/5/2018 ★☆☆ Medium Array c++
793. K-th Smallest Prime Fraction Hard Binary Search c++
825.Friends Of Appropriate Ages 10/5/2018 Medium Array c++
830. Positions of Large Groups 7/8/2018 Easy Array c++
832.Flipping an Image 7/8/2018 Easy Array c++
840.Magic Squares In Grid 7/10/2018 Easy Array c++
849.Maximize Distance to Closest Person 7/10/2018 Easy Array c++
852. Peak Index in a Mountain Array 10/5/2018 Easy Binary Search c++
868. Transpose Matrix 7/8/2018 Easy Array c++
402. Remove K Digits 8/20/2018 Medium Stack Greedy c++
273.Integer to English Words 8/21/2018 Hard String Math c++
171. Excel Sheet Column Number 8/21/2018 Easy Math c++
223. Rectangle Area 8/21/2018 Medium Math c++
658. Find K Closest Elements 8/21/2018 Medium Binary Search c++
232. Implement Queue using Stacks 8/21/2018 Easy Stack Design c++
116. Populating Next Right Pointers in Each Node 8/21/2018 Medium Tree Depth-first Search c++
191. Number of 1 Bits 8/21/2018 Easy Bit Manipulation c++
237.Delete Node in a Linked List 8/22/2018 Medium Linked List c++
10. Regular Expression Matching × Hard Backtracking String Dynamic Programming c++
695.Max Area of Island 8/23/2018 Easy Array Depth-first Search c++
415.Add Strings 8/23/2018 Easy Math c++
445.Add Two Numbers II 8/27/2018 Medium Linked List Math c++
43 ★☆☆ Medium `` c++
212. Word Search II 10/5/2018 ★☆☆ Hard BackTracking Trie c++
2.Add Two Numbers 8/27/2018 Medium Linked List Math c++
525. Contiguous Array 8/27/2018 Medium Hash Table c++
187. Repeated DNA Sequences 8/28/2018 Medium Hash Table Bit Manipulation c++
347.Top K Frequent Elements 8/28/2018 Medium Hash Table Heap c++
200.Number of Islands 10/5/2018 ★☆☆ Medium Depth-first Search Breadth-first Search Union Find c++
305. Number of Islands II 9/17/2018 ☆☆☆ Hard Union Find c++
208. Implement Trie (Prefix Tree) 10/6/2018 ☆☆☆ Medium Trie Design c++
297. Serialize and Deserialize Binary Tree 10/6/2018 ☆☆☆ Hard Tree Design c++
173. Binary Search Tree Iterator 10/6/2018 ☆☆☆ Medium Tree Design Stack c++
117. Populating Next Right Pointers in Each Node II 10/6/2018 ☆☆☆ Hard Binary Search Tree c++
114. Flatten Binary Tree to Linked List 10.6.2018 ☆☆☆ Medium Tree Depth-first Search c++
24. Swap Nodes in Pairs 10/6/2018 ★☆☆ Medium Linked List c++
23. Merge k Sorted Lists 10/7/2018 ★☆☆ Hard Linked List Divide and Conquer Heap c++
25. Reverse Nodes in k-Group 10/7/2018 ★☆☆ Hard Linked List c++
71. Simplify Path ignore Medium Stack String c++
5. Longest Palindromic Substring 10/7/2018 ★☆☆ Medium Dynamic Programming String c++
91. Decode Ways 10/7/2018 ★☆☆ Medium Dynamic Programming String c++
125. Valid Palindrome ignore Easy Two Pointers String c++
8. String to Integer (atoi) ignore Medium String Math c++
215.Kth Largest Element in an Array 10/7/2018 ★☆☆ Medium Heap Divide and Conquer c++
168.Excel Sheet Column Title 10/7/2018 ★☆☆ Medium Math c++
258.Add Digits 10/7/2018 ★☆☆ Medium Math c++
207. Course Schedule 10/7/2018 ★☆☆ Medium Depth-first Search Breadth-first Search Graph Topological Sort c++
692.Top K Frequent Words 10/7/2018 ★☆☆ Medium Hash Table Heap Trie c++
328.Odd Even Linked List 10/7/2018 Medium Linked List c++
329.Longest Increasing Path in a Matrix 10/7/2018 ★☆☆ Hard Depth-first Search Topological Sort Memoization c++
284. Peeking Iterator 11/7/2018 ★☆☆ Medium Design c++
7. Reverse Integer 11/7/2018 ★☆☆ Easy Math c++
221. Maximal Square 11/7/2018 ★☆☆ Medium Dynamic Programming c++
Medium c++
Medium c++
Medium c++
Medium c++
Medium c++

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages