My own practice for LeetCode exercise.
# |
Problem |
Solution |
Difficulty |
Related Topics/Ideas |
64 |
Minimum Path Sum |
C++ |
Medium |
2020/12/11 basic dp |
72 |
Edit Distance |
C++ |
Hard |
2020/09/22 dp string, similar to 376 HW2 |
123 |
Best Time to Buy and Sell Stock III |
C++ |
Hard |
2020/08/16 daily exercise, dynamic programming, also comes with a neat solution |
486 |
Predict the Winner |
C++ |
Medium |
2020/09/01 daily exercise, dynamic programming |
546 |
Remove Boxes |
C++ |
Hard |
2020/08/15 daily exercise, dynamic programming |
647 |
Palindromic Substrings |
C++ |
Medium |
2020/08/19 daily exercise, dynamic programming, & Manacher algorithm |
877 |
Stone Game |
C++ |
Medium |
2020/09/01 daily exercise, dynamic programming, similar to 486, also comes with a trivial sol. |
983 |
Minimum Cost For Tickets |
C++ |
Medium |
2020/08/25 daily exercise, dynamic programming, dfs |
# |
Problem |
Solution |
Difficulty |
Related Topics/Ideas |
4 |
Median of Two Sorted Arrays |
C++ |
Hard |
O(log(m+n)) Binary Search, Tricky Boundaries & Type conversion |
15 |
3Sum |
C++ |
Medium |
While this problem has some trivial solutions, it is a good practice on Nesting Unordered Map (O(1) Search), which examines trade-off of search complexity and construction complexity |
50 |
Pow(x, n) |
C++ |
Medium |
Fast Power Algorithm O(logn) , overflow |
101 |
Symmetric Tree |
C++ |
Easy |
280 In-class Exercise, Binary trees, recursion |
148 |
Sort List |
Python |
Medium |
Merge Sort, Linked List |
436 |
Find Right Interval |
C++ |
Medium |
2020/08/27 daily exercise, binary search using map |
# |
Problem |
Solution |
Difficulty |
Related Topics/Ideas |
17 |
Letter Combinations of a Phone Number |
C++ |
Medium |
2020/08/26 daily exercise, dfs |
332 |
Reconstruct Itinerary |
C++ |
Medium |
2020/08/27 daily exercise, dfs & hash map, backtrack |
491 |
Increasing Subsequences |
C++ |
Medium |
2020/08/25 daily exercise, subsequence, dfs |
529 |
Minesweeper |
C++ |
Medium |
2020/08/20 daily exercise, basic dfs (do not use reference to modifies click). |
679 |
24 Game |
C++ |
Hard |
2020/08/22 daily exercise, basic iteration & dfs |
733 |
Flood Fill |
C++ |
Easy |
2020/08/16 daily exercise, basic dfs. |
841 |
Keys and Rooms |
C++ |
Medium |
2020/08/31 daily exercise, basic dfs. |
949 |
Largest Time for Given Digits |
C++ |
Easy |
2020/09/01 daily exericse, permutation, bfs |
952 |
Largest Component Size by Common Factor |
C++ |
Hard |
2020/08/30 daily exercise, union find |
967 |
Numbers With Same Consecutive Differences |
C++ |
Medium |
2020/08/18 daily exercise, basic bfs. |
983 |
Minimum Cost For Tickets |
C++ |
Medium |
2020/08/25 daily exercise, dynamic programming, dfs |
# |
Problem |
Solution |
Difficulty |
Related Topics/Ideas |
435 |
Non-overlapping Intervals |
C++ |
Medium |
2020/08/15 daily exercise, basic greedy algorithm. |
# |
Problem |
Solution |
Difficulty |
Related Topics/Ideas |
101 |
Symmetric Tree |
C++ |
Easy |
280 In-class Exercise, Binary trees, recursion |
102 |
Binary Tree Level Order Traversal |
C++ |
Medium |
2020/12/07, level order traversal (bfs) |
105 |
Construct Binary Tree from Preorder and Inorder Traversal |
C++ |
Medium |
2020/12/01, tree construction, use index rather than construct new vector to save memory |
109 |
Convert Sorted List to Binary Search Tree |
C++ |
Medium |
2020/08/18 daily exercise, in-order traversal, median |
110 |
Balanced Binary Tree |
C++ |
Easy |
2020/08/17 daily exercise, bottom-up recursion, avoid calculating height multiple times |
111 |
Minimum Depth of Binary Tree |
C++ |
Easy |
2020/08/21 daily exercise, basic dfs (pay attention to leaf node) |
404 |
Sum of Left Leaves |
C++ |
Easy |
2020/08/24 daily exercise, left leaf node. |
437 |
Path Sum III |
C++ |
Medium |
2020/08/08 daily exercise, interesting recursion. |
450 |
Delete Node in a BST |
C++ |
Medium |
2020/08/31 daily exercise, delete note recursively |
589 |
N-ary Tree Preorder Traversal |
C++ |
Easy |
280 In-class Exercise, n-ary tree, recursion vs. iteration |
987 |
Vertical Order Traversal of a Binary Tree |
C++ |
Medium |
2020/08/07 daily exercise, comp + recursion. |
1032 |
Stream of Characters |
C++ |
Hard |
2020/08/23 daily exercise, union of chars, trie |
# |
Problem |
Solution |
Difficulty |
Related Topics/Ideas |
1 |
Two Sum |
C++ |
Easy |
280 In-class Exercise, Unordered Map (O(1) search) |
15 |
3Sum |
C++ |
Medium |
While this problem has some trivial solutions, it is a good practice on Nesting Unordered Map (O(1) Search), which examines trade-off of search complexity and construction complexity |
20 |
Valid Parentheses |
C++ |
Easy |
2020/08/14 daily exercise, stack & hash map (unordered_map) |
211 |
Design Add and Search Words Data Structure |
C++ |
Medium |
2020/08/05 daily exercise, use unordered_map to realize dictionary with fast search |
332 |
Reconstruct Itinerary |
C++ |
Medium |
2020/08/27 daily exercise, dfs & hash map, backtrack |
409 |
Longest Palindrome |
C++ |
Easy |
2020/08/14 daily exercise, hash map (unordered_map) |
705 |
Design HashSet |
C++ |
Easy |
2020/08/02 daily exercise, implement a hashset |
771 |
Jewels and Stones |
C++ |
Easy |
Unordered Map, O(1) Search. |
1032 |
Stream of Characters |
C++ |
Hard |
2020/08/23 daily exercise, union of chars, trie |
# |
Problem |
Solution |
Difficulty |
Related Topics/Ideas |
125 |
Valid Palindrome |
C++ |
Easy |
2020/08/03 daily exercise, tricky boundaries (upper & lowercase, distance between '0' and 'P') |
171 |
Excel Sheet Column Number |
C++ |
Easy |
2020/08/09 daily exercise, reverse & base conversion |
214 |
Shortest Palindrome |
C++ |
Hard |
2020/08/29 daily exercise, Manacher algorithm (for palindromic) + KMP algorithm (for searching substring with next[] represents last searched pos) |
415 |
Add Strings |
C++ |
Easy |
280 In-class Exercise, Operation of big integers using string |
459 |
Repeated Substring Pattern |
C++ |
Easy |
2020/08/24 daily exercise, substring, KMP algorithm (for searching substring with next[] represents last searched pos) |
520 |
Detect Capital |
C++ |
Easy |
2020/08/01 daily exercise, basic string |
557 |
Reverse Words in a String III |
C++ |
Easy |
2020/08/30 daily exercise, basic string |
567 |
Permutation in String |
C++ |
Medium |
280 In-class Exercise, substring & sliding-window |
647 |
Palindromic Substrings |
C++ |
Medium |
2020/08/19 daily exercise, dynamic programming, & Manacher algorithm (for palindromic) |
824 |
Goat Latin |
C++ |
Easy |
2020/08/19 daily exercise, basic stringstream |
949 |
Largest Time for Given Digits |
C++ |
Easy |
2020/09/01 daily exericse, permutation, bfs |
1032 |
Stream of Characters |
C++ |
Hard |
2020/08/23 daily exercise, union of chars, trie |
# |
Problem |
Solution |
Difficulty |
Related Topics/Ideas |
50 |
Pow(x, n) |
C++ |
Medium |
Fast Power Algorithm O(logn) , overflow |
119 |
Pascal’s Triangle II |
C++ |
Easy |
2020/08/12 daily exercise, combination |
120 |
Triangle |
C++ |
Medium |
Minimum path sum |
168 |
Excel Sheet Column Title |
C++ |
Easy |
280 In-class Exercise, funny but tricky number base conversion (not beginning from 0) |
201 |
Bitwise AND of Numbers Range |
C++ |
Medium |
2020/08/23 daily exercise, bitwise AND & Brian Kernighan. |
204 |
Count Primes |
C++ |
Easy |
Sieve of Euler, O(n) |
258 |
Add Digits |
C++ |
Easy |
280 In-class Exercise, abc = a+b+c mod 9 & Boundary conditions. |
342 |
Power of Four |
C++ |
Easy |
2020/08/04 daily exercise, log and power |
412 |
Fizz Buzz |
C++ |
Easy |
2020/08/26 daily exercise, mod |
415 |
Add Strings |
C++ |
Easy |
280 In-class Exercise, Operation of big integers using string |
470 |
Implement Rand10() Using Rand7() |
C++ |
Medium |
2020/08/28 daily exercise, random, reject sampling |
497 |
Random Point in Non-overlapping Rectangles |
C++ |
Medium |
2020/08/22 daily exercise, random |
551 |
Student Attendance Record I |
C++ |
Easy |
280 In-class Exercise |
567 |
Permutation in String |
C++ |
Medium |
280 In-class Exercise, substring & sliding-window |
657 |
Robot Return to Origin |
C++ |
Easy |
2020/08/28 daily exercise, simulation |
969 |
Pancake Sorting |
C++ |
Medium |
2020/08/29 daily exercise, interesting sorting |
1103 |
Distribute Candies to People |
C++ |
Easy |
2020/08/17 daily exercise, mod boundaries cases consideration |
1200 |
Minimum Absolute Difference |
C++ |
Easy |
280 In-class Exercise |
剑指 Offer 20 |
剑指 Offer 20. 表示数值的字符串 |
C++ |
Medium |
2020/09/02 daily exercise, FSM, simulation |