| Date | LeetCode Problem | GitHub Gist | Data Structure / Pattern | Difficulty | Notes |
|---|---|---|---|---|---|
| 8-26-2022 | 101. Symmetric Tree | GitHub Gist | Binary Tree | Easy | REVIEW THIS: Learn the recursive solution |
| 8-26-2022 | 283. Move Zeroes | GitHub Gist | Array | Easy | Create a pointer at the first element; loop over the array: if the current element is not 0, replace it with the index value & increment the pointer. After that loop, start from the pointer index, and reassign all values from there and after to 0 |
| 8-2-2022 | 773. Sliding Puzzle | GitHub Gist | Graph / BFS | Hard | Use a serialize / deserialize function; store the serialize grid + # steps in a hashmap; compare all possible swaps with the current "0" coordinate |
| 8-2-2022 | 127. Word Ladder | GitHub Gist | Graph / BFS | Hard | REVIEW THIS |
| 7-21-2022 | 542. 01 Matrix | GitHub Gist | Graph / BFS | Medium | Similar to Gates and Walls but requires visited array |
| 7-21-2022 | 286. Walls and Gates | GitHub Gist | Graph / BFS | Medium | REVIEW: Push the GATES into a queue, then find the empty spaces and increment the counts of those |
| 7-20-2022 | 1197. Minimum Knight Moves | GitHub Gist | Graph / BFS | Medium | Very similar to Binary Tree Right Side View Approach; i.e. use an inner loop to verify when you are evaluating a particular level based on the current queue.length |
| 7-20-2022 | 111. Minimum Depth of Binary Trees | GitHub Gist | Binary Tree / BFS | Easy | Like Max Depth, but no need to keep track; Use BFS and return the level immediately upon finding a leaf node (i.e. first/shallowest leaf) |
| 7-18-2022 | 199. Binary Tree Right Side View | GitHub Gist | Binary Tree / BFS | Medium | INNER LOOP: While a count variable is less than the queue length (i.e. the length of this level, already created during the last evaluation), push the next level into the queue and increment the count. |
| 7-13-2022 | 74. Search a 2D Matrix | GitHub Gists | 2D Array / Array / Grid / Binary Search | Medium | TIP: Given 2D array matrix, you can find the row & col from the INDEX (as if it were a single array) of a particular element: row = index / numElements & col = index % numElementss |
| 7-12-2022 | 366. Find Leaves of Binary Trees | GitHub Gist | Binary Tree / DFS | Medium | REVIEW THIS |
| 6-30-2022 | 463. Island Perimeter | GitHub Gist | Graph / BFS / DFS | Easy | Simple DFS; trick is to substract one from the possible 4 perimeter units each time you find an node adjacent (TRBL) to the current node |
| 6-29-2022 | 17. Letter Combinations of a Phone Number | GitHub Gist | Backtracking / String | Medium | PRACTICE THIS PATTERN |
| 6-29-2022 | 46. Permutations | GitHub Gist | Backtracking / Array | Medium | PRACTICE THIS PATTERN |
| 6-27-2022 | 257. Binary Tree Paths | GitHub Gist | Binary Tree | Easy | Remember: Base case is when there are no left/right or children nodes; For Tenary / N-ary tree, deal with children rather than left/right |
| 6-24-2022 | 628. Maximum Product of Three Numbers | GitHub Gist | Array / Math | Easy | Remember: Number.MIN_VALUE represents the smallest positive number |
| 6-23-2022 | 701. Insert into a Binary Search Tree | GitHub Gist | Binary Search Tree | Medium | Remember: recursively add the new node the left subtree if val is less than the current, otherwise add to the right |
| |6-23-2022 |200. Number of Islands | GitHub Gist | Graph / BFS | Medium | 1. Loop through the grid (nested loop); 2. Use queue/BFS to evaluate the valid adjacent vertices of any "island" & add to count when all valid island vertices have been seen; 3. Loop with continue the process with any unconnected islands. |6-22-2022 |34. Find First and Last Position of Element in Sorted Array | GitHub Gist | Binary Search | Medium | Use a helper function and "TRUE/FALSE" parameter (isFirst) to clean up the code for the 2-pass binary search | | 6-22-2022 | 215. Kth Largest Element in an Array | GitHub Gist | Sorting / Quicksort / Hoare's Quickselect | Medium | REVIEW THIS | | 6-20-2022 | 236. Lowest Common Ancestor of a Binary Tree | GitHub Gist | Tree / DFS | Medium | REVIEW THIS | |6-16-2022 |297. Serialize and Deserialize Binary Tree | GitHub Gist | Binary Tree / DFS | Hard | Remember the procedure for CREATING a binary tree based on a type of traversal | 6-15-2022 |110. Balanced Binary Tree | GitHub Gist | Binary Tree | Easy | REVIEW - comparing depths of subtrees | |6-14-2022 |1011. Capacity To Ship Packages Within D Days | GitHub Gist | Array / Binary Search | Medium | REMEMBER: Binary Search - find the BOUNDARY pattern | | 6-14-2022 | 744. Find Smallest Letter Greater Than Target | GitHub Gist | Array / Binary Search | Easy | Binary Search | | 6-14-2022 | 169. Majority Element | GitHub Gist | Array / Hashtable / Divide and Conquer | Easy | REVIEW: Boyer-Moore Algorithm; Easy approach uses hashtable | |6-10-2022 | 160. Intersection of Two Linked Lists | GitHub Gist | Linked List | Easy (with Medium solution) | like fast / slow pointers, you can traverse the list up to twice to find intersection by restarting one list's pointer when it reaches null, then returning one of the pointer vals when the pointers are equal (if no intersection, both will equal null) | |6-7-2022 | 105. Construct Binary Tree from Preorder and Inorder Traversal | | Binary Tree | Medium | Remember the IMPORTANT FACTS to solve this: 1. 1st element in pre-order array is root node and 2. | 6-7-2022 | 230. Kth Smallest Element in a BST | GitHub Gist | Binary Search Tree / In-Order Traversal | Medium | Review the Iterative Solution | |6-7-2022 | 572. Subtree of Another Tree | GitHub Gist | Binary Tree / DFS | Easy | Combine traversal and "same tree" pattern | |6-7-2022 | 235. Lowest Common Ancestor of a Binary Search Tree | GitHub Gist | Binary Tree / DFS | Easy | REMEMBER: The LCA in a BST is the node at which the value of one target node is less than and the other greater than the ancestor value. |6-4-2022 | 102. Binary Tree Level Order Traversal | GitHub Gist | Binary Tree / DFS / BFS | Medium | TIP: create OR push into each level subarray; REVIEW: keeping track of tree level | |6-4-2022 |238. Product of Array Except Self | GitHub Gist | Array | Medium | BIG-O TIP: Iterating through an array twice (non-nested) DOES NOT MATTER; still O(n) time |6-4-2022 | 98. Validate Binary Search Tree | GitHub Gist | Binary Search Tree | Medium | REMEMBER: choosing DFS method is important - this can rely on IN-ORDER TRAVERSAL |6-3-2022 | 83. Remove Duplicates from Sorted List | GitHub Gist | Linked List | Easy | Since it's sorted, no need to store duplicate values (dupes will be directly next to each other) | |6-2-2022 | 141. Linked List Cycle | GitHub Gist | Linked List / Two-Pointers | Easy | Floyd's Tortoise and Hare | |6-2-2022 | 66.Plus One |GitHub Gist | Array | Easy | Remember to keep edge cases in mind, e.g. [9,9,9] or [8,9,8] |6-2-2022 | 28. Implement strStr() |GitHub Gist | String / Two-Pointers | Easy | Carefully consider how to break out of a loop and/or properly return a result ONLY IF the loop completes successfully |6-1-2022 | 746. Min Cost Climbing Stairs | GitHub Gist | Dynamic Programming / Array | Easy | Update existing array (similar to maximum subarray); change the logic as needed | |6-1-2022 | 70. Climbing Stairs | GitHub Gist | Dynamic Programming | Easy | Look for the pattern between steps to make the appropriate calculations | | 6-1-2022 | 867. Transpose Matrix | GitHub Gist | Array / Matrix / Simulation | Easy | Construct the matrix in the opposite direction (rows <--> columns) | |6-1-2022 | 1448. Count Good Nodes in Binary Tree | GitHub Gist |Binary Tree / Recursion / Depth-First Search | Medium | REVIEW THIS SOLUTION | | 6-1-2022 |226. Invert Binary Tree | GitHub Gist | Binary Tree | Easy | REVIEW THIS SOLUTION; particularly DFS | | 6-1-2022 | 1249. Minimum Remove to Make Valid Parentheses | GitHub Gist | String / Stack | Medium | Use stack and convert to array; replace un-needed elements with empty string | | 6-1-2022 | 123. Best Time to Buy and Sell Stock III | GitHub Gist | Array / Dynamic Programming | Medium | REVIEW THIS ALGORITHM | |6-1-2022 | 678. Valid Parenthesis String | GitHub Gist | String / Greedy | Medium | REVIEW: Greedy algorithm - keeps track of min and max left parens | |5-31-2022 | 430. Flatten a Multilevel Doubly Linked List | GitHub Gist | Doubly-Linked List | Medium | REMEMBER: consider the order the nodes will be evaluated AFTER merging children |5-31-2022 | 58. Length of Last Word | GitHub Gist | String | Easy | REMEMBER: Consider all edge cases (e.g. ending spaces) |5-27-2022 | 122. Best Time to Buy and Sell Stock II | GitHub Gist | Array / Sliding Windows | Medium | REMEMBER one-pass approach! Just like first problem // Review: Sliding Windows - Peak and Valley Approach | |5-27-2022 | 159. Longest Substring with At Most Two Distinct Characters | GitHub Gist | Array / Sliding Windows | Medium | Classic sliding windows BUT remember the pattern for updating the hashmap for "max 'k' distinct characters | | 5-26-2022 | 69. Sqrt(x) | GitHub Gist | Binary Search | Easy | Tip: You can iterate over a series of numbers without an array | |5-26-2022 | 852. Peak Index in a Mountain Array | GitHub Gist | Array / Binary Search | Easy | REMEMBER: Binary Search Pattern | |5-26-2022 | 92. Reverse Linked List II | GitHub Gist | Linked List | Medium | REVIEW THIS; there are 4 necessary pointers | |5-26-2022 | 206. Reverse Linked List | GitHub Gist | Linked List / Recursion | Easy | Remember to store the appropriate pointers to keep references on reassignment |5-26-2022 | 53. Maximum Subarray | GitHub Gist | Array / Dynamic Programming | Easy | Dynamic Programming: Kadane's Algorithm | |5-25-2022 | 680. Valid Palindrome II | GitHub Gist | String / Two-Pointers | Easy | Two-Pointers: start evaluating palindrome. If mismatch, use helper to compare the remaining substrings using current pointer values |5-25-2022 | 125. Valid Palindrome | GitHub Gist | String / Two-Pointers | Easy | Two-Pointers options: 1. Start from ends; 2. Start from middle; 3. Create reverse copy of string |5-25-2022 | 27. Remove Element | GitHub Gist | Array / Two-Pointers | Easy | Fast/Slow pointers: Slow pointer only moves when fast pointer encounters a number that is not the val (in this case, the val at p1 is replaced by val at p2) |5-24-2022 | 3. Longest Substring Without Repeating Characters | GitHub Gist | String / Sliding Windows | Medium | Sliding Windows: Keep track of left bound, hashmap (character + index) and max. Loop over array (right pointer): If seen character before, move left bound to this hashmap value + 1; regardless, add current character/index to hashmap and update the max (max between current or p2-p1+1) |5-24-2022 | 844. Backspace String Compare | GitHub Gist | String / Two-Pointers | Easy | Two-Pointers: start at end of each string; if the values at any pointer is "#", figure out how many spaces to back (keep track of hashes * 2); Otherwise, compare letter characters and return false if they don't match. |5-24-2022 | 42. Trapping Rain Water | GitHub Gist | Array / Two-Pointers | Hard | Two pointers at start/end; evaluate the side with the lesser value; add the difference between the max height on that side and the current value to the total water calculation; increment |5-20-2022 | 11. Container With Most Water | GitHub Gist | Array / Two-Pointers | Medium | Two pointers (start/end) and a maxArea variable; replace maxArea if current area is larger; increment the pointer at the lesser value | |5-20-2022 |547. Number of Provinces | GitHub Gist | Graph / BFS | Medium | NOT like number of islands; each array represents a city and each nested array element represents the connection to the other cities, BFS + visited array to count any cities you have NOT already seen | |5-19-2022 |1. Two Sum | GitHub Gist | Array / Two-Pointer / HashMap | Easy | Hashmap Implementation to store the difference needed | | 5-19-2022 |121. Best Time to Buy and Sell Stock | GitHub Gist| Array / Dynamic Programming | Easy | Track max difference and minimum input |5-18-2022 | 1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree | GitHub Gist | Binary Tree / DFS | Easy | Recursively reassign left <--> right | 5-18-2022 | 14. Prefix | GitHub Gist | String | Easy | Recursively divide-and-conquer to compare halves |5-18-2022 | 13. Roman to Integer | GitHub Gist | Hashtable / String | Easy | Use the math to create the rules |5-18-2022 | 1971. Find if Path Exists in Graph |GitHub Gist | Graph / BFS | Easy | BFS: queue and visited array for each vertex | |5-17-2022 | 1091. Shortest Path in Binary Matrix | GitHub Gist| Graph / Breadth-First Search | Medium | BFS works best to catch the first path quickly, track visited nodes |5-15-2022 | 104. Maximum Depth of Binary Tree |GitHub Gist | Graph / Depth-First Search | Easy | |5-15-2022 | 1302. Deepest Leaves Sum| GitHub Gist | Graph / Depth-First Search | Medium | | 5-14-2022 | 73. Set Matrix Zeroes | GitHub Gist| Array / Matrix | Medium | | 5-14-2022 | 1791. Find Center of Star Graph | GitHub Gist| Graph | Easy | | 5-14-2022 | 203. Remove Linked List Elements | GitHub Gist | Linked List / Recursion | Easy | | 5-13-2022 | 1006. Clumsy Factorial |GitHub Gist | Math / Stack | Medium | | 5-11-2022 | 234. Palindrome Linked List| GitHub Gist | Two-Pointers / Recursion | Easy | | 5-11-2022 | 142. Linked List Cycle II | GitHub Gist| Two-Pointers / Recursion | Medium | Store visited in hashmap OR FLOYD'S TORTOISE AND HARE ALGORITHM: fast/slow pointers to return 'null' if fast never equals slow, or return 'slow' if fast ever equals slow | | 5-11-2022 | 509. Fibonacci Number | GitHub Gist| Recursion / Memoization | Easy | | 5-10-2022 | 997. Find the Town Judge | GitHub Gist| Graph / Array | Easy | Need only find the any vertex that has n-1 indegress and no outdegrees (just keep a running count +1 for indegrees and -1 for outdegrees) | 5-6-2022 | 359. Logger Rate Limiter | | Hash Table | Easy | |5-6-2022 | 1469. Find All The Lonely Nodes | | Depth First Search | Easy | | 5-6-2022 | 136. Single Number |GitHub Gist| Array | Easy | | 5-6-2022 | 1689. Partitioning Into Minimum Number Of Deci-Binary Numbers | GitHub Gist| String / Greedy | Medium | Find/return largest integer digit; Tip: JS converts number "string" into integers for comparison (e.g. "3" < "4") | | 5-6-2022 | 1874. Minimize Product Sum of Two Arrays |GitHub Gist | Array / Greedy | Easy | Recognize: rearranging ONLY ONE array is the same as sorting both and doesn't impact the outcome. Don't get bogged down in this detail.