Writing & Teaching are the best ways of learning and understanding.
0 Warning(s), 0 Error(s). π
Bitwise | Number & Math | String | Linked List | Array | Tree | BST | Binary Search | Priority Queue | Backtracking | Dynamic Programming | Greedy | Graph | Trie | Design
[Review Policy] By repeatedly reviewing I can get: π(x1), π(x2), πΌ(x3), π(x4), π(x5), β¦, TBD.
Notes (Summary)
- Recursion Runtime Patterns π
- Divide And Conquer Notes Recursion TreeMaster Theorem π
- Dynamic Programming Notes π Top-DownBottom-Up
- Backtracking Notes π₯ Backtracking vs. DFS
- Binary Search Template Notes Lower/Upper Bound
[lo, hi)
&[lo, hi]
π - TreeSet/TreeMap Usage & binarySearch() Tree MapArrays & Collections
Solve a Problem, Write a Post
Reference: LeetCode & Elements of Programming Interviews in Java
Bitwise
- 136. Single Number I, II, III MediumEPI 11.10
- 191. Number of 1 Bits Easyx & (x - 1)x & ~(x - 1)EPI 4.1
- 338. Counting Bits MediumDP π
- 477. Total Hamming Distance MediumEPI 4.4
- 50. Pow(x, n) Medium
- 371. Sum of Two Integers EasyAdd Two NumbersNot Easy
Number & Math
- Duplicate & Missing
- 268. Missing Number Easy π
- 287. Find the Duplicate Number MediumCycle Detection π
- 645. Set Mismatch EasyBit ManipulationEPI 11.10 π
- 41. First Missing Positive Hard
- Primality
- 204. Count Primes EasySieve of Eratosthenes
- Majority
- 169. Majority Element EasyBoyer-Moore Majority Vote Algorithm
- 229. Majority Element II Medium
- Uncategorized
- 9. Palindrome Number EasyEPI 4.9
- 66. Plus One / 369. Plus One Linked List EasyIt is easy compared to 2. Add Two Numbers
- 231. Power of Two / 326. Power of Three / 342. Power of Four Easy
- 13. Roman to Integer / 12. Integer to Roman EasyEPI 6.8
- 202. Happy Number EasyCycle Detection
- 263. Ugly Number I & II MediumPrimePriority QueueDP
- 780. Reaching Points Hard
- 273. Integer to English Words Hard
String
- Basic
- EPI 6.1 | Interconvert Strings and Integers String <-> IntegerEPI 6.1
- 8. String to Integer (atoi) EasyPhD in Corner Cases
- 541. Reverse String II EasyGroup Index Practice
- 151. Reverse Words in a String I Medium
- 186. Reverse Words in a String II MediumIn-PlaceEPI 6.6
- 557. Reverse Words in a String III EasySimplified Version of II
- 819. Most Common Word EasyRegex
- 412. Fizz Buzz Easy
- Palindrome
- 125. Valid Palindrome I & II EasyTwo PointersEPI 6.5
- 266. Palindrome Permutation I EasyHash Table
- 267. Palindrome Permutation II MediumBacktracking
- EPI 15.8 | Generate Palindromic Decompositions BacktrackingTime ComplexityEPI 15.8
- 647. Palindromic Substrings MediumExpansionDP π
- 5. Longest Palindromic Substring MediumExpansionDP π
- 516. Longest Palindromic Subsequence MediumDFSDP π
- Uncategorized
- 1002. Find Common Characters EasyA bit strange
- 451. Sort Characters By Frequency Medium
- 271. Encode and Decode Strings Medium
- 937. Reorder Data in Log Files EasyComparatorSucks ππ
- 6. ZigZag Conversion MediumIndex Practice
- 38. Count and Say EasyIndex Practice
- 468. Validate IP Address Medium
- OA | Substring of Size K with K Distinct Chars MediumSliding WindowHash Set
- 49. Group Anagrams MediumHash Mapsorting
- 953. Verifying an Alien Dictionary Easy
Linked List
- Add / Merge Two Lists
- 2. Add Two Numbers Medium ππ
- 445. Add Two Numbers II Medium ππ
- 21. Merge Two Sorted Lists EasyEPI 7.1 ππ
- 23. Merge k Sorted Lists HardEPI 10.1 ππ
- Reverse / Swap List
- 206. Reverse Linked List Easy (gist) ππ
- 92. Reverse Linked List II MediumEPI 7.2 ππ
- 25. Reverse Nodes in k-Group HardEPI 7.2 ππ
- 24. Swap Nodes in Pairs Medium ππ
- Cycle Detection
- 141. Linked List Cycle I EasyTwo Pointers ππ
- 142. Linked List Cycle II MediumTwo PointersEPI 7.3 ππ
- Sort List
- 147. Insertion Sort List Medium ππ
- 148. Sort List MediumSlow/Fast Pointers ππ
- Uncategorized
- 234. Palindrome Linked List EasyTwo Pointers π
- 160. Intersection of Two Linked Lists EasyTwo PointersEPI 7.4 ππ
- 61. Rotate List Medium π
- 817. Linked List Components Medium π
- 328. Odd Even Linked List Medium
- 725. Split Linked List in Parts Medium
- 138. Copy List with Random Pointer MediumDeep Copy π
- 203. Remove Linked List Elements EasyDummy
Array
- N-Sum
- 1. Two Sum EasyHash TableUsed OnceElements are not necessarily unique π
- 167. Two Sum II (sorted) EasyHash TableBinary SearchTwo PointersUsed Once π
- 170. Two Sum III (data structure design) EasyTwo SetsCount Map π
- 653. Two Sum IV (BST) EasyBSTA Tree Problem π
- 1214. Two Sum BSTs MediumTwo Pointers π
- 1099. Two Sum Less Than K EasySorting & Two Pointers π
- EPI 17.4 | The 3-Sum Problem Hash TableBinary SearchTwo PointersUsed >1EPI 17.4 π
- 15. 3Sum MediumTwo PointersUsed OnceDifficult to handle duplicate triplets π
- 259. 3Sum Smaller MediumTwo PointersAllow Duplicate Pairs π
- 18. 4Sum MediumTwo Pointers π
- Subarray Sum
- 560. Subarray Sum Equals K MediumHash Map
- 325. Maximum Size Subarray Sum Equals K MediumHash Map
- 525. Contiguous Array MediumTo Be Done
- 209. Minimum Size Subarray Sum MediumTree MapBinary SearchTwo Pointers
- 862. Shortest Subarray with Sum at Least K HardTo Be Done (Negative Allowed)
- 76. Minimum Window Substring HardTo Be Done (Same Idea on Two Pointers)
- Sliding Window
- 219. Contains Duplicate II EasyHash Mapk-size Set π
- 220. Contains Duplicate III MediumTree Set π
- 239. Sliding Window Maximum HardPriority QueueDequeDP π
- 992. Subarrays with K Distinct Integers HardSliding Window
- Intersection
- 349. Intersection of Two Arrays EasyHash Table π
- 350. Intersection of Two Arrays II EasyHash TableBinary SearchTwo Pointers π
- Duplicates
- 26. Remove Duplicates from Sorted Array EasyEPI 5.5 π
- 217. Contains Duplicate I EasyHash SetSorting π
- In-Place Removal / Swapping
- EPI 5.1 | The Dutch National Flag Problem 3-Way PartitionSortingEPI 5.1
- 561. Array Partition I EasyPermutation
- 27. Remove Element EasyTwo PointersRare vs. Many
- 283. Move Zeroes EasyTwo Pointers
- Buy and Sell Stocks & Similar Problems
- EPI 5.6 | Longest Subarray with Equal elements One-PassEPI 5.6 Variant
- 53. Maximum Subarray Easydivide-and-conquerDP
- 121. Best Time to Buy and Sell Stock Easydivide-and-conquerOne-PassEPI 5.6
- Uncategorized
- 88. Merge Sorted Array EasyTwo PointersEPI 13.2
- EPI 5.4 | Advancing Through an Array GreedyDFSEPI 5.4
- 189. Rotate Array EasyIn-Place
- 11. Container With Most Water MediumTwo Pointers
- 56. Merge Intervals Medium
- 945. Minimum Increment to Make Array Unique MediumSorting
- 532. K-diff Pairs in an Array EasyHash Map
- 739. Daily Temperatures MediumStack
- 695. Max Area of Island MediumDFS
- 200. Number of Islands MediumDFSBFS
- 694. Number of Distinct Islands MediumDFSHash Table
- 289. Game of Life Medium
- 73. Set Matrix Zeroes Medium
- 31. Next Permutation Medium
Tree
- Traversal
- 94. Binary Tree Inorder Traversal MediumMorris Traversal ππ
- 144. Binary Tree Preorder Traversal MediumMorris Traversal ππ
- 145. Binary Tree Postorder Traversal HardPreorder-likeInorder-like ππ
- EPI 9.10 | Binary Tree Traversals with Parent EPI 9.10Not Common π
- 102. Binary Tree Level Order Traversal I & II MediumPreorderBFS ππ
- 429. N-ary Tree Level Order Traversal Easy ππ
- 589. N-ary Tree Preorder Traversal Easy ππ
- 987. Vertical Order Traversal of a Binary Tree Medium ππ
- 114. Flatten Binary Tree to Linked List Medium ππ
- Equality & Subtree
- 100. Same Tree Easy ππ
- 101. Symmetric Tree EasyDFSBFSEPI 9.2 ππ
- 572. Subtree of Another Tree EasyPreorder Sequence Comparison ππ
- Height & Depth
- 104. Maximum Depth of Binary Tree Easy π
- 110. Balanced Binary Tree Easy π
- 111. Minimum Depth of Binary Tree Easy π
- 236. Lowest Common Ancestor of a Binary Tree MediumEPI 9.3EPI 9.4
- 235. Lowest Common Ancestor of a Binary Search Tree EasyEPI 14.4
- Sum & Path
- EPI 9.5 | Sum Root-To-Leaf Paths of Binary Tree (Binary Data) EPI 9.5 π
- 129. Sum Root to Leaf Numbers (Decimal Data) Medium EPI 9.5 π
- 112. Path Sum EasyEPI 9.6 π
- 113. Path Sum II Medium π
- 437. Path Sum III EasyNot Easy, Prefix Sum is difficult to understand π
- 257. Binary Tree Paths Easy π
- Using Max / Min Field
- 543. Diameter of Binary Tree EasySimple Version of 124
- 124. Binary Tree Maximum Path Sum Hard π
- 687. Longest Univalue Path EasyAnother Version of 124. Not Easy
- Pruning & Trimming
- 814. Binary Tree Pruning MediumGreat Problem π
- 669. Trim a Binary Search Tree Easy π
- Recovery & Construction
- 105. Construct Binary Tree from Preorder / Postorder and Inorder Traversal Medium EPI 9.11
- 108. Convert Sorted Array / List to Binary Search Tree EasyMedium EPI 14.8 π
- 99. Recover Binary Search Tree Hard
- 1028. Recover a Tree From Preorder Traversal Hard
- 297. Serialize and Deserialize Binary Tree Hard
- 428. Serialize and Deserialize N-ary Tree Medium
- 449. Serialize and Deserialize BST Medium
- Binary Search Tree (BST)
- 98. Validate Binary Search Tree MediumEPI 14.1 π
- 285. Inorder Successor in BST Medium π
- 510. Inorder Successor in BST II MediumEPI 9.9 π
- 701. Insert into a Binary Search Tree Medium π
- 450. Delete Node in a BST Medium π
- 230. Kth Smallest Element in a BST MediumEPI 14.3 π
- 530. Minimum Absolute Difference in BST Easy π
- 501. Find Mode in Binary Search Tree Easy
- 173. Binary Search Tree Iterator Medium
- Uncategorized
- 617. Merge Two Binary Trees Easy
- 654. Maximum Binary Tree Medium
Binary Search
- Basic Search
- Rotated Sorted Array
- 153. Find Minimum in Rotated Sorted Array MediumFor Problem 33divide-and-conquer
- 154. Find Minimum in Rotated Sorted Array II HardFor Problem 81divide-and-conquer
- 33 / 81. Search in Rotated Sorted Array I & II Medium
- Matrix
- 74. Search a 2D Matrix MediumEPI 11.6
- 240. Search a 2D Matrix II MediumEPI 11.6
- 378. Kth Smallest Element in a Sorted Matrix MediumEPI 11.6
- Uncategorized
- 367. Valid Perfect Square EasyEPI 11.4
- 633. Sum of Square Numbers Easy
- 29. Divide Two Integers Medium
- 4. Median of Two Sorted Arrays Hard
- 162. Find Peak Element MediumVery Strange
Priority Queue
- 347. Top K Frequent Elements / 692. Top K Frequent Words Medium ππ
- 215. Kth Largest Element in an Array MediumQuick SelectEPI 11.8
- 973. K Closest Points to Origin Medium Very Similar to 215Quick SelectEPI 10.4 ππ
- 295. Find Median from Data Stream HardBinary Search Templates ππ
- 659. Split Array into Consecutive Subsequences MediumGreedy
- 407. Trapping Rain Water II Hard
- 1102. Path With Maximum Minimum Value MediumBacktrackingHeapVariant -> DP
Backtracking
- Basic
- 46. Permutations I & II MediumEPI 15.4
- 77. CombinationsMediumEPI 15.6
- 78. Subsets I & II MediumStartIndexInteresting!EPI 15.5
- 17. Letter Combinations of a Phone Number MediumStartIndexSimilar to SubsetsEPI 15.2
- 39. Combination Sum I & II & III Medium
- Parentheses
- 20. Valid Parentheses EasyStackNot Backtracking
- 22. Generate Parentheses MediumEPI 15.7
- 301. Remove Invalid Parentheses Hard
- Uncategorized
- 89. Gray Code MediumEPI 15.11
- 93. Restore IP Addresses MediumEPI 6.9
- 51. N-Queens I & II Hard
- 36. Valid Sudoku MediumHash Table
- 37. Sudoku Solver Hard
- 79. Word Search I & II Medium
- 139. Word Break I MediumDP
- 140. Word Break II HardDP
Dynamic Programming
- 70. Climbing Stairs EasyCounting
- 746. Min Cost Climbing Stairs EasyOptimizationIndex!
- εηηΊΏ
- 62. Unique Paths I & II MediumCountingProblem II is very great!
- εηηΊΏ
- 96. Unique Binary Search Trees I MediumCountingEPI 15.9
- 95. Unique Binary Search Trees II MediumCountingClone a Tree
- εηηΊΏ
- 845. Longest Mountain in Array MediumOne Pointer
- 42. Trapping Rain Water HardTwo Pointersdivide-and-conquerDP
- 1D w/ Multiple States / dp[i][0], dp[i][1], dp[i][2]
- 256. Paint House EasyOptimization
- 926. Flip String to Monotone Increasing Mediumdp[i][0] & dp[i][1]Challenging
Greedy
- 134. Gas Station MediumEPI 17.6
Graph
- 133. Clone Graph MediumDeep Copy π
- 785. Is Graph Bipartite? MediumDFS
- 547. Friend Circles MediumDFS
- 1192. Critical Connections in a Network HardDFSTarjanβs Algorithm
- 207. Course Schedule I & II MediumCycleDFSBFSTopological Sort
- 269. Alien Dictionary HardBFSTopological Sort953. Verifying an Alien Dictionary
Trie
- 208. Implement Trie (Prefix Tree) MediumCS 61B Tries π
- 421. Maximum XOR of Two Numbers in an Array MediumTrie Practice
Design
- 707. Design Linked List Easy ππ
- 155. Min Stack EasyOne Stack ππ
- 716. Max Stack EasyTwo Stacks ππ
- 146. LRU Cache MediumLinkedHashMap
- 460. LFU Cache HardLinkedHashSet
- 341. Flatten Nested List Iterator MediumStackRecursion
- 794. Valid Tic-Tac-Toe State Medium