Some Common Leetcode Problems For Tech Interviews
To be honest, I really hate to practice Leetcode problems. But I know that it is kind of the standard of in the tech interview, it's better to practice so that we can use the same language with interviewer.
Below are some common leedcode problems which cover almost all important topics for any software interview. I got the list mainly from https://seanprashad.com/leetcode-patterns/
| No | Challenge name | Topics | Difficulty |
|---|---|---|---|
| 1 | Contains Duplicate | Array | Easy |
| 2 | Missing Number | Arrays, Bit Manipulation | Easy |
| 3 | Find All Numbers Disappeared in an Array | Arrays | Easy |
| 4 | Single Number | Arrays, Bit Manipulation | Easy |
| 5 | Climbing Stairs | Dynamic Programming | Easy |
| 6 | Best Time to Buy and Sell Stock | Greedy | Easy |
| 7 | Maximum Subarray | Dynamic Programming | Easy |
| 8 | Range Sum Query - Immutable | Dynamic Programming | Easy |
| 9 | Counting Bits | Dynamic Programming, Bit Manipulation | Easy |
| 10 | Linked List Cycle | Fast & Slow Pointers | Easy |
| 11 | Middle of the Linked List | Fast & Slow Pointers | Easy |
| 12 | Palindrome Linked List | Fast & Slow Pointers | Easy |
| 13 | Remove Linked List Elements | Fast & Slow Pointers | Easy |
| 14 | Remove Duplicates from Sorted List | Fast & Slow Pointers | Easy |
| 15 | Reverse Linked List | In-place reversal of a linked list | Easy |
| 16 | Merge Two Sorted Lists | Two Pointers | Easy |
| 17 | Meeting Rooms | Intervals | Easy |
| 18 | Binary Search | Binary Search | Easy |
| 19 | Find Smallest Letter Greater Than Target | Binary Search | Easy |
| 20 | Peak Index in a Mountain Array | Binary Search | Easy |
| 21 | Average of Levels in Binary Tree | BFS | Easy |
| 22 | Minimum Depth of Binary Tree | BFSDFS | Easy |
| 23 | Same Tree | DFS | Easy |
| 24 | Path Sum | DFS | Easy |
| 25 | Maximum Depth of Binary Tree | DFS | Easy |
| 26 | Diameter of Binary Tree | DFS | Easy |
| 27 | Merge Two Binary Trees | DFS | Easy |
| 28 | Lowest Common Ancestor of a Binary Search Tree | DFS | Easy |
| 29 | Subtree of Another Tree | DFS | Easy |
| 30 | Invert Binary Tree | DFS | Easy |
| 31 | Two Sum | Two Pointers | Easy |
| 32 | Squares of a Sorted Array | Two Pointers | Easy |
| 33 | Backspace String Compare | Two Pointers | Easy |
| 34 | Index Pairs of a String | Trie | Easy |
| 35 | Majority Element | Sorting | Easy |
| 36 | Convert 1D Array Into 2D Array | Arrays | Easy |
| 37 | Product of Array Except Self | Arrays | Medium |
| 38 | Find the Duplicate Number | ArraysBinary SearchTwo Pointers | Medium |
| 39 | Find All Duplicates in an Array | Arrays | Medium |
| 40 | Set Matrix Zeroes | Arrays | Medium |
| 41 | Spiral Matrix | Arrays | Medium |
| 42 | Rotate Image | Arrays | Medium |
| 43 | Word Search | Backtracking | Medium |
| 44 | Longest Consecutive Sequence | Arrays | Medium |
| 45 | Letter Case Permutation | Backtracking | Medium |
| 46 | Subsets | Backtracking | Medium |
| 47 | Subsets II | Backtracking | Medium |
| 48 | Permutations | Backtracking | Medium |
| 49 | Permutations II | Backtracking | Medium |
| 50 | Combinations | Backtracking | Medium |
| 51 | Combination Sum | Backtracking | Medium |
| 52 | Combination Sum II | Backtracking | Medium |
| 53 | Combination Sum III | Backtracking | Medium |
| 54 | Generate Parentheses | Backtracking | Medium |
| 55 | Target Sum | DFSDynamic Programming | Medium |
| 56 | Palindrome Partitioning | Backtracking | Medium |
| 57 | Letter Combinations of a Phone Number | Backtracking | Medium |
| 58 | Generalized Abbreviation | Backtracking | Medium |
| 59 | House Robber | Dynamic Programming | Medium |
| 60 | House Robber II | Dynamic Programming | Medium |
| 61 | Coin Change | Dynamic Programming | Medium |
| 62 | Maximum Product Subarray | Dynamic Programming | Medium |
| 63 | Longest Increasing Subsequence | Dynamic Programming | Medium |
| 64 | Longest Palindromic Substring | Dynamic Programming | Medium |
| 65 | Word Break | Dynamic Programming | Medium |
| 66 | Combination Sum IV | Dynamic Programming | Medium |
| 67 | Decode Ways | Dynamic Programming | Medium |
| 68 | Unique Paths | Dynamic Programming | Medium |
| 69 | Jump Game | Dynamic ProgrammingGreedy | Medium |
| 70 | Palindromic Substrings | Dynamic Programming | Medium |
| 71 | Number of Longest Increasing Subsequence | Dynamic Programming | Medium |
| 72 | Partition Equal Subset Sum | Dynamic Programming | Medium |
| 73 | Partition to K Equal Sum Subsets | Dynamic Programming | Medium |
| 74 | Best Time to Buy and Sell Stock with Cooldown | Dynamic Programming | Medium |
| 75 | Linked List Cycle II | Fast & Slow Pointers | Medium |
| 76 | Add Two Numbers | Fast & Slow Pointers | Medium |
| 77 | Remove Nth Node From End Of List | Fast & Slow Pointers | Medium |
| 78 | Sort List | Fast & Slow Pointers | Medium |
| 79 | Reorder List | Fast & Slow Pointers | Medium |
| 80 | Clone Graph | BFS, DFS, Graph | Medium |
| 81 | Pacific Atlantic Water Flow | BFS, DFS | Medium |
| 82 | Number of Islands | BFS, DFS, Union Find | Medium |
| 83 | Graph Valid Tree | BFS, DFS Graph Union Find | Medium |
| 84 | Number of Connected Components in an Undirected Graph | BFS, DFS, Graph, Union Find | Medium |
| 85 | Reverse Linked List II | In-place reversal of a linked list | Medium |
| 86 | Rotate List | In-place reversal of a linked list | Medium |
| 87 | Swap Nodes in Pairs | In-place reversal of a linked list | Medium |
| 88 | Odd Even Linked List | In-place reversal of a linked list | Medium |
| 89 | Kth Smallest Element in a Sorted Matrix | Binary SearchHeap | Medium |
| 90 | Find K Pairs with Smallest Sums | Heap | Medium |
| 91 | Merge Intervals | Intervals | Medium |
| 92 | Interval List Intersections | Intervals | Medium |
| 93 | Non-overlapping Intervals | Intervals | Medium |
| 94 | Meeting Rooms II | HeapIntervals | Medium |
| 95 | Task Scheduler | GreedyHeap | Medium |
| 96 | Minimum Number of Arrows to Burst Balloons | Greedy | Medium |
| 97 | Insert Interval | Intervals | Medium |
| 98 | Find Minimum in Rotated Sorted Array | Binary Search | Medium |
| 99 | Find Peak Element | Binary Search | Medium |
| 100 | Search in Rotated Sorted Array | Binary Search | Medium |
| 101 | Search in Rotated Sorted Array II | Binary Search | Medium |
| 102 | Search a 2D Matrix | Binary Search | Medium |
| 103 | Search a 2D Matrix II | Binary Search | Medium |
| 104 | Find K Closest Elements | Binary Search | Medium |
| 105 | Minimum Size Subarray Sum | Sliding Window | Medium |
| 106 | Fruit Into Baskets | Sliding Window | Medium |
| 107 | Permutation in String | Sliding Window | Medium |
| 108 | Longest Repeating Character Replacement | Sliding Window | Medium |
| 109 | Longest Substring Without Repeating Characters | Sliding Window | Medium |
| 110 | Kth Smallest Element in a BST | DFS | Medium |
| 111 | K Closest Points to Origin | Heap | Medium |
| 112 | Top K Frequent Elements | Heap | Medium |
| 113 | Sort Characters By Frequency | Heap | Medium |
| 114 | Kth Largest Element in an Array | HeapQuickSelect | Medium |
| 115 | Reorganize String | GreedyHeap | Medium |
| 116 | Course Schedule | BFS, DFS, GraphTopological Sort | Medium |
| 117 | Course Schedule II | BFS, DFS, GraphTopological Sort | Medium |
| 118 | Minimum Height Trees | BFS, GraphTopological Sort | Medium |
| 119 | Sequence Reconstruction | Graph, Topological Sort | Medium |
| 120 | Binary Tree Level Order Traversal II | BFS | Medium |
| 121 | Binary Tree Level Order Traversal | BFS | Medium |
| 123 | Binary Tree Zigzag Level Order Traversal | BFS | Medium |
| 124 | Populating Next Right Pointers in Each Node | BFS | Medium |
| 125 | Populating Next Right Pointers in Each Node II | BFS | Medium |
| 126 | Binary Tree Right Side View | BFS, DFS | Medium |
| 127 | All Nodes Distance K in Binary Tree | BFS, DFS | Medium |
| 128 | Path Sum II | DFS | Medium |
| 129 | Path Sum III | DFS | Medium |
| 130 | Lowest Common Ancestor of a Binary Tree | DFS | Medium |
| 131 | Maximum Binary Tree | DFS | Medium |
| 132 | Maximum Width of Binary Tree | DFS | Medium |
| 133 | Construct Binary Tree from Preorder and Inorder Traversal | DFS | Medium |
| 134 | Validate Binary Search Tree | DFS | Medium |
| 135 | Implement Trie (Prefix Tree) | DesignTrie | Medium |
| 136 | 3 Sum | Two Pointers | Medium |
| 137 | 3 Sum Closest | Two Pointers | Medium |
| 138 | Subarrays with Product Less than K | Two Pointers | Medium |
| 139 | Sort Colours | Two Pointers | Medium |
| 140 | Container With Most Water | Two Pointers | Medium |
| 141 | Longest Word in Dictionary | Trie | Medium |
| 142 | Maximum XOR of Two Numbers in an Array | Trie | Medium |
| 143 | First Missing Positive | Arrays | Hard |
| 144 | Sudoku Solver | Backtracking | Hard |
| 145 | N-Queens | Backtracking | Hard |
| 146 | Reverse Nodes in k-Group | In-place reversal of a linked list | Hard |
| 147 | Merge k Sorted Lists | Heap | Hard |
| 148 | Smallest Range Covering Elements from K Lists | Heap | Hard |
| 149 | Employee Free Time | Heap, Greedy | Hard |
| 150 | Count of Range Sum | Binary Search | Hard |
| 151 | Sliding Window Maximum | Sliding Window | Hard |
| 152 | Minimum Number of K Consecutive Bit Flips | Sliding Window | Hard |
| 153 | Count Unique Characters of All Substrings of a Given String | Sliding Window | Hard |
| 154 | Minimum Window Substring | Sliding Window | Hard |
| 155 | Substring with Concatenation of All Words | Sliding Window | Hard |
| 156 | Rearrange String k Distance Apart | Greedy, Heap | Hard |
| 157 | Course Schedule III | Greedy, Heap | Hard |
| 158 | Maximum Frequency Stack | Bucket Sor, tHeap | Hard |
| 159 | Alien Dictionary | Graph,Topological Sort | Hard |
| 160 | Binary Tree Maximum Path Sum | DFS | Hard |
| 161 | Serialize and Deserialize Binary Tree | Design | Hard |
| 162 | Word Search II | DFS, Trie | Hard |
| 163 | Find Median from Data Stream | Heap | Hard |
| 164 | Sliding Window Median | Heap | Hard |
| 165 | Trapping Rain Water | Two Pointers | Hard |
| 166 | Concatenated Words | Trie | Hard |
| 167 | Prefix and Suffix Search | Trie | Hard |
| 168 | Palindrome Pairs | Trie | Hard |
| 169 | Design Search Autocomplete System | Trie | Hard |
| 170 | Word Squares | Trie | Hard |
| 171 | Sort Items by Groups Respecting Dependencies | DFS, Graph, Topological Sort | Hard |
| 172 | Median of Two Sorted Arrays | Binary Search | Hard |
Over the time, I also try to understand what is the usage behind those problems. This leads me to an awsome course on Educative Decode the Coding Interview in Java: Real-World Examples.