/LeetCode

Practice At https://leetcode.com/

Primary LanguageC++

LeetCode

Notes

  1. Backtracking
  2. Largest Sum Contiguous Subarray
  3. KMP
  4. Sliding Window Algorithm
  5. Dynamic Programming
  6. Greedy Algorithm
  7. Graph
  8. Binary Tree
  9. Bit Algorithms
  10. Pattern Searching
  11. Math Algorithms
  12. Geometric Algorithms
  13. Trie

Progress

Problem Answer Tags Comment
001. Two Sum CPP Array, Hash Table
015. 3Sum CPP Array Cool
016. 3Sum Closest CPP Array
017. Letter Combinations of a Phone Number CPP String, Backtracking
020. Valid Parentheses CPP String, Stack
022. Generate Parentheses CPP String, Backtracking, DP
026. Remove Duplicates from Sorted Array CPP Array Cool
027. Remove Element CPP Array
035. Search Insert Position CPP Array
039. Combination Sum CPP Array, Backtracking
051. NQueens CPP Backtracking Wow
052. NQueensII CPP Backtracking
088. Merge Sorted Array CPP Array
118. Pascal's Triangle CPP Array
217. Contains Duplicate CPP Array
219. Contains Duplicate II CPP Array
283. Move Zeroes CPP Array
321. Create Maximum Number CPP DP, Greedy
402. Remove K Digits CPP Stack, Greedy
414. Third Maximum Number CPP Array COOL
670. Maximum Swap CPP Array, Math
674. Longest Continuous Increasing Subsequence CPP Array
189. Rotate Array CPP Array
448. Find All Numbers Disappeared in an Array CPP Array
485. Max Consecutive Ones CPP Array
532. K-diff Pairs in an Array CPP Array
605. Can Place Flowers CPP Array
628. Maximum Product of Three Numbers CPP Array
661. Image Smoother CPP Array
167. Two Sum II - Input array is sorted CPP Array COOL
169. Majority Element CPP Array COOL
268. Missing Number CPP Array, Math, Bit Manipulation COOL
66. Plus One CPP Array
581. Shortest Unsorted Continuous Subarray CPP Array
119. Pascal's Triangle II CPP Array
643. Maximum Average Subarray I CPP Array Sliding Window
695. Max Area of Island CPP Array, DFS COOL
53. Maximum Subarray CPP Array, DP
561. Array Partition I CPP Array, Bucket Sort COOL
665. Non-decreasing Array CPP Array
566. Reshape the Matrix CPP Array
121. Best Time to Buy and Sell Stock CPP Array COOL
122. Best Time to Buy and Sell Stock II CPP Array
123. Best Time to Buy and Sell Stock III CPP Array, DP NASTY
188. Best Time to Buy and Sell Stock IV CPP Array, DP NASTY
309. Best Time to Buy and Sell Stock with Cooldown CPP Array, DP NASTY
714. Best Time to Buy and Sell Stock with Transaction Fee CPP Array,DP NASTY
137. Single Number II CPP Array, Bit COOL
260. Single Number III CPP Array, Bit COOL
41. First Missing Positive CPP Array

Array Easy: 2017.9.15 -- 2017.10.12

Problem Answer Tags Comment
686. Repeated String Match CPP String, KMP COOL
681. Next Closest Time CPP String COOL,Simulation
459. Repeated Substring Pattern CPP String
415. Add Strings CPP String Need Survey
43. Multiply Strings CPP String Need Survey
125. Valid Palindrome CPP String Need Survey
680. Valid Palindrom II CPP String
38. Count and Say CPP String
657. Judge Route Circle CPP String
606. Construct String from Binary Tree CPP String COOL
652. Find Duplicate Subtrees CPP String COOL
13. Roman to Integer CPP String
14. Longest Common Prefix CPP String 边界测试很重要!
541. Reverse String II CPP String
557. Reverse Words in a String III CPP String
551. Student Attendance Record I CPP String
28. Implement strStr() CPP String
520. Detect Capital CPP String
443. String Compression CPP String
434. Number of Segments in a String CPP String
67. Add Binary CPP String
387. First Unique Character in a String CPP String
383. Ransom Note CPP String
521. Longest Uncommon Subsequence I CPP String
345. Reverse Vowels of a String CPP String

String Easy: 2017.10.12 -- 2018.1.4

Need to learn->

  1. string matching. DONE
Problem Answer Tags Comment
389. Find the Difference CPP HashTable
350. Intersectin of Two Arrays II CPP HashTable
447. Number of Boomerangs CPP HashTable 有点意思
336. Palindrome Pairs CPP HashTable WOWOWOWOW
690. Employee Importance CPP HashTable
463. Island Perimeter CPP HashTable
500. Keyboard Row CPP HashTable
349. Intersection of Two Arrays CPP HashTable
645. Set Mismatch CPP HashTable
136. Single Number CPP HashTable, Bit
720. Longest Word in Dictionary CPP HashTable Fun
438. Find All Anagrams in a String CPP HashTable Sliding Window
76. Minimum Window Substring CPP HashTable Sliding Window
159 Longest Substring with At Most Two Distinct Characters CPP HashTable Sliding Window
340 Longest Substring with At Most K Distinct Characters CPP HashTable Sliding Window
760. Find Anagram Mappings CPP HashTable
599. Minimum Index Sum of Two Lists CPP HashTable
242. Valid Anagram CPP HashTable
205. Isomorphic Strings CPP HashTable
204. Count Primes CPP HashTable COOL
202. Happy Number CPP HashTable
594. Longest Harmonious Subsequence CPP HashTable
575. Distribute Candies CPP HashTable
409. Longest Palindrome CPP HashTable
138. Copy List with Random Pointer CPP HashTable, Linked List

HashTable Easy: 2018.1.5 -- 2018.1.12

Problem Answer Tags Comment
746. Min Cost Climbing Stairs CPP DP COOL
303. Range Sum Query - Immutable CPP DP
198. House Robber CPP DP
70. Climbing Stairs CPP DP
300. Longest Increasing Subsequence CPP DP
376. Wiggle Subsequence CPP DP Important
467. Unique Substrings in Wraparound String CPP DP Tricky
650. 2 Keys Keyboard CPP DP Tricky
91. Decode Ways CPP DP COOL
96. Unique Binary Search Trees CPP DP Interesting
95. Unique Binary Search Trees II CPP DP Interesting
474. Ones and Zeroes CPP DP Interesting
42. Trapping Rain Water CPP DP FUN

Dynamic Programming 2018.1.14 --2018.1.18

Problem Answer Tags Comment
455. Assign Cookies CPP Greedy
649. Dota2 Senate CPP Greedy COOL
763. Partition Labels CPP Greedy Nasty
435. Non-overlapping Intervals CPP Greedy
55. Jump Game CPP Greedy
134. Gas Station CPP Greedy
406. Queue Reconstruction by Height CPP Greedy Nasty
621. Task Scheduler CPP Greedy COOL
767. Reorganize String CPP Greedy
630. Course Schedule III CPP Greedy So COOL

Greedy Algorithm 2018.1.19 -- 2018.1.27

Problem Answer Tags Comment
733. Flood Fill CPP DFS COOL
239. Sliding Window Maximum CPP Queue Nice
112. Path Sum CPP DFS
100. Same Tree CPP DFS COOL
101. Symmetric Tree CPP DFS COOL
104. Maximum Depth of Binary Tree CPP DFS,BFS
108. Convert Sorted Array to Binary Search Tree CPP DFS
111. Minimum Depth of Binary Tree CPP DFS
257. Binary Tree Paths CPP DFS Useful
102. Binary Tree Level Order Traversal CPP BFS, DFS
107. Binary Tree Level Order Traversal II CPP BFS, DFS
637. Average of Levels in Binary Tree CPP BFS, DFS
662. Maximum Width of Binary Tree CPP BFS, DFS Nice
752. Open the Lock CPP BFS COOOOL
103. Binary Tree Zigzag Level Order Traversal CPP BFS,DFS
515. Find Largest Value in Each Tree Row CPP BFS
529. Minesweeper CPP BFS
490. The Maze CPP BFS, DFS (not test)
417. Pacific Atlantic Water Flow CPP BFS
329. Longest Increasing Path in a Matrix CPP DFS
98. Validate Binary Search Tree CPP MidOrderTraverse COOL
99. Recover Binary Search Tree CPP Morris Traversal

BFS,DFS 2018.1.28 -- 2018.2.27

Problem Answer Tags Comment
743. Network Delay Time CPP Dijkstra
133. Clone Graph CPP DFS, BFS COOOL
207. Course Schedule CPP DFS, BFS
337. Course Schedule II CPP DFS, Topological Sorting, BFS
310. Minimum Height Trees CPP BFS, Graph SOOOO COOL
332. Reconstruct Itinerary CPP DFS, Greedy, Eulerian Path SOOOO COOL
399. Evaluate Division CPP DFS, hash SOOOO COOL
684. Redundant Connection CPP Degree, Union Find Nice
685. Redundant Connection II CPP DFS Nice
785. Is Graph Bipartite? CPP BFS, Graph Coloring Nice
765. Couples Holding Hands CPP cyclic swapping WOWOWOW

Tree, Graph 2018.2.27 -- 2018.3.13

Problem Answer Tags Comment
扩充:Mini Swap Array CPP cyclic swapping COOL
Problem Answer Tags Comment
2. Add Two Numbers CPP
4. Median of Two Sorted Arrays CPP WOWOWOWOW
5. Longest Palindromic Substring CPP Middle Out COOOL
6. ZigZag Conversion CPP String Aha
7. Reverse Integer CPP Math
8. String to Integer (atoi) CPP String
9. Palindrome Number CPP Math
11. Container With Most Water CPP Array
12. Integer to Roman CPP Array TODO...
21. Merge Two Sorted Lists CPP Linked List Important
23. Merge k Sorted Lists CPP Linked List
46. Permutations CPP Backtracking
69. Sqrt(x) CPP Math

1-100 2018.3.13 --

Problem Answer Tags Comment
A* search algorithm CPP Graph COOL

Other(Not Leetcode)

Tips

  1. 使用 vector 下标索引元素时,提醒自己下标是否合法,vector 是否为空,有没有对一些极端情况作出处理。

LeetCode

Notes

  1. Backtracking
  2. Largest Sum Contiguous Subarray
  3. KMP
  4. Sliding Window Algorithm
  5. Dynamic Programming
  6. Greedy Algorithm
  7. Graph
  8. Binary Tree
  9. Bit Algorithms
  10. Pattern Searching
  11. Math Algorithms
  12. Geometric Algorithms
  13. Trie

Progress

Problem Answer Tags Comment
001. Two Sum CPP Array, Hash Table
015. 3Sum CPP Array Cool
016. 3Sum Closest CPP Array
017. Letter Combinations of a Phone Number CPP String, Backtracking
020. Valid Parentheses CPP String, Stack
022. Generate Parentheses CPP String, Backtracking, DP
026. Remove Duplicates from Sorted Array CPP Array Cool
027. Remove Element CPP Array
035. Search Insert Position CPP Array
039. Combination Sum CPP Array, Backtracking
051. NQueens CPP Backtracking Wow
052. NQueensII CPP Backtracking
088. Merge Sorted Array CPP Array
118. Pascal's Triangle CPP Array
217. Contains Duplicate CPP Array
219. Contains Duplicate II CPP Array
283. Move Zeroes CPP Array
321. Create Maximum Number CPP DP, Greedy
402. Remove K Digits CPP Stack, Greedy
414. Third Maximum Number CPP Array COOL
670. Maximum Swap CPP Array, Math
674. Longest Continuous Increasing Subsequence CPP Array
189. Rotate Array CPP Array
448. Find All Numbers Disappeared in an Array CPP Array
485. Max Consecutive Ones CPP Array
532. K-diff Pairs in an Array CPP Array
605. Can Place Flowers CPP Array
628. Maximum Product of Three Numbers CPP Array
661. Image Smoother CPP Array
167. Two Sum II - Input array is sorted CPP Array COOL
169. Majority Element CPP Array COOL
268. Missing Number CPP Array, Math, Bit Manipulation COOL
66. Plus One CPP Array
581. Shortest Unsorted Continuous Subarray CPP Array
119. Pascal's Triangle II CPP Array
643. Maximum Average Subarray I CPP Array Sliding Window
695. Max Area of Island CPP Array, DFS COOL
53. Maximum Subarray CPP Array, DP
561. Array Partition I CPP Array, Bucket Sort COOL
665. Non-decreasing Array CPP Array
566. Reshape the Matrix CPP Array
121. Best Time to Buy and Sell Stock CPP Array COOL
122. Best Time to Buy and Sell Stock II CPP Array
123. Best Time to Buy and Sell Stock III CPP Array, DP NASTY
188. Best Time to Buy and Sell Stock IV CPP Array, DP NASTY
309. Best Time to Buy and Sell Stock with Cooldown CPP Array, DP NASTY
714. Best Time to Buy and Sell Stock with Transaction Fee CPP Array,DP NASTY
137. Single Number II CPP Array, Bit COOL
260. Single Number III CPP Array, Bit COOL
41. First Missing Positive CPP Array

Array Easy: 2017.9.15 -- 2017.10.12

Problem Answer Tags Comment
686. Repeated String Match CPP String, KMP COOL
681. Next Closest Time CPP String COOL,Simulation
459. Repeated Substring Pattern CPP String
415. Add Strings CPP String Need Survey
43. Multiply Strings CPP String Need Survey
125. Valid Palindrome CPP String Need Survey
680. Valid Palindrom II CPP String
38. Count and Say CPP String
657. Judge Route Circle CPP String
606. Construct String from Binary Tree CPP String COOL
652. Find Duplicate Subtrees CPP String COOL
13. Roman to Integer CPP String
14. Longest Common Prefix CPP String 边界测试很重要!
541. Reverse String II CPP String
557. Reverse Words in a String III CPP String
551. Student Attendance Record I CPP String
28. Implement strStr() CPP String
520. Detect Capital CPP String
443. String Compression CPP String
434. Number of Segments in a String CPP String
67. Add Binary CPP String
387. First Unique Character in a String CPP String
383. Ransom Note CPP String
521. Longest Uncommon Subsequence I CPP String
345. Reverse Vowels of a String CPP String

String Easy: 2017.10.12 -- 2018.1.4

Need to learn->

  1. string matching. DONE
Problem Answer Tags Comment
389. Find the Difference CPP HashTable
350. Intersectin of Two Arrays II CPP HashTable
447. Number of Boomerangs CPP HashTable 有点意思
336. Palindrome Pairs CPP HashTable WOWOWOWOW
690. Employee Importance CPP HashTable
463. Island Perimeter CPP HashTable
500. Keyboard Row CPP HashTable
349. Intersection of Two Arrays CPP HashTable
645. Set Mismatch CPP HashTable
136. Single Number CPP HashTable, Bit
720. Longest Word in Dictionary CPP HashTable Fun
438. Find All Anagrams in a String CPP HashTable Sliding Window
76. Minimum Window Substring CPP HashTable Sliding Window
159 Longest Substring with At Most Two Distinct Characters CPP HashTable Sliding Window
340 Longest Substring with At Most K Distinct Characters CPP HashTable Sliding Window
760. Find Anagram Mappings CPP HashTable
599. Minimum Index Sum of Two Lists CPP HashTable
242. Valid Anagram CPP HashTable
205. Isomorphic Strings CPP HashTable
204. Count Primes CPP HashTable COOL
202. Happy Number CPP HashTable
594. Longest Harmonious Subsequence CPP HashTable
575. Distribute Candies CPP HashTable
409. Longest Palindrome CPP HashTable
138. Copy List with Random Pointer CPP HashTable, Linked List

HashTable Easy: 2018.1.5 -- 2018.1.12

Problem Answer Tags Comment
746. Min Cost Climbing Stairs CPP DP COOL
303. Range Sum Query - Immutable CPP DP
198. House Robber CPP DP
70. Climbing Stairs CPP DP
300. Longest Increasing Subsequence CPP DP
376. Wiggle Subsequence CPP DP Important
467. Unique Substrings in Wraparound String CPP DP Tricky
650. 2 Keys Keyboard CPP DP Tricky
91. Decode Ways CPP DP COOL
96. Unique Binary Search Trees CPP DP Interesting
95. Unique Binary Search Trees II CPP DP Interesting
474. Ones and Zeroes CPP DP Interesting
42. Trapping Rain Water CPP DP FUN

Dynamic Programming 2018.1.14 --2018.1.18

Problem Answer Tags Comment
455. Assign Cookies CPP Greedy
649. Dota2 Senate CPP Greedy COOL
763. Partition Labels CPP Greedy Nasty
435. Non-overlapping Intervals CPP Greedy
55. Jump Game CPP Greedy
134. Gas Station CPP Greedy
406. Queue Reconstruction by Height CPP Greedy Nasty
621. Task Scheduler CPP Greedy COOL
767. Reorganize String CPP Greedy
630. Course Schedule III CPP Greedy So COOL

Greedy Algorithm 2018.1.19 -- 2018.1.27

Problem Answer Tags Comment
733. Flood Fill CPP DFS COOL
239. Sliding Window Maximum CPP Queue Nice
112. Path Sum CPP DFS
100. Same Tree CPP DFS COOL
101. Symmetric Tree CPP DFS COOL
104. Maximum Depth of Binary Tree CPP DFS,BFS
108. Convert Sorted Array to Binary Search Tree CPP DFS
111. Minimum Depth of Binary Tree CPP DFS
257. Binary Tree Paths CPP DFS Useful
102. Binary Tree Level Order Traversal CPP BFS, DFS
107. Binary Tree Level Order Traversal II CPP BFS, DFS
637. Average of Levels in Binary Tree CPP BFS, DFS
662. Maximum Width of Binary Tree CPP BFS, DFS Nice
752. Open the Lock CPP BFS COOOOL
103. Binary Tree Zigzag Level Order Traversal CPP BFS,DFS
515. Find Largest Value in Each Tree Row CPP BFS
529. Minesweeper CPP BFS
490. The Maze CPP BFS, DFS (not test)
417. Pacific Atlantic Water Flow CPP BFS
329. Longest Increasing Path in a Matrix CPP DFS
98. Validate Binary Search Tree CPP MidOrderTraverse COOL
99. Recover Binary Search Tree CPP Morris Traversal

BFS,DFS 2018.1.28 -- 2018.2.27

Problem Answer Tags Comment
743. Network Delay Time CPP Dijkstra
133. Clone Graph CPP DFS, BFS COOOL
207. Course Schedule CPP DFS, BFS
337. Course Schedule II CPP DFS, Topological Sorting, BFS
310. Minimum Height Trees CPP BFS, Graph SOOOO COOL
332. Reconstruct Itinerary CPP DFS, Greedy, Eulerian Path SOOOO COOL
399. Evaluate Division CPP DFS, hash SOOOO COOL
684. Redundant Connection CPP Degree, Union Find Nice
685. Redundant Connection II CPP DFS Nice
785. Is Graph Bipartite? CPP BFS, Graph Coloring Nice
765. Couples Holding Hands CPP cyclic swapping WOWOWOW

Tree, Graph 2018.2.27 -- 2018.3.13

Problem Answer Tags Comment
扩充:Mini Swap Array CPP cyclic swapping COOL
Problem Answer Tags Comment
2. Add Two Numbers CPP
4. Median of Two Sorted Arrays CPP WOWOWOWOW
5. Longest Palindromic Substring CPP Middle Out COOOL
6. ZigZag Conversion CPP String Aha
7. Reverse Integer CPP Math
8. String to Integer (atoi) CPP String
9. Palindrome Number CPP Math
11. Container With Most Water CPP Array
12. Integer to Roman CPP Array TODO...
21. Merge Two Sorted Lists CPP Linked List Important
23. Merge k Sorted Lists CPP Linked List
46. Permutations CPP Backtracking
69. Sqrt(x) CPP Math

1-100 2018.3.13 --

Problem Answer Tags Comment
A* search algorithm CPP Graph COOL

Other(Not Leetcode)

Tips

  1. 使用 vector 下标索引元素时,提醒自己下标是否合法,vector 是否为空,有没有对一些极端情况作出处理。