- Interview Questions
- /
- Problems
Most-asked coding interview problems
The 100 problems tagged by the most companies in our interview dataset. Each page lets you write and test a solution in Python or JavaScript in your browser, then walks through the approach from brute force to optimal.
| Problem | Pattern | Difficulty | Companies |
|---|---|---|---|
| Two Sum | Hash map of complements | Easy | 196 |
| LRU Cache | Hash map + doubly linked list | Medium | 196 |
| Number of Islands | Flood fill (DFS/BFS on a grid) | Medium | 189 |
| Merge Intervals | Sort, then sweep | Medium | 183 |
| Valid Parentheses | Stack of open brackets | Easy | 180 |
| Longest Palindromic Substring | Expand around center | Medium | 166 |
| Longest Substring Without Repeating Characters | Sliding window with last-seen index | Medium | 165 |
| Best Time to Buy and Sell Stock | Running minimum | Easy | 163 |
| Trapping Rain Water | Two pointers with running maximums | Hard | 161 |
| Group Anagrams | Hash map keyed by a canonical form | Medium | 156 |
| Container With Most Water | Two pointers from both ends | Medium | 153 |
| Maximum Subarray | Kadane's algorithm | Medium | 149 |
| Search in Rotated Sorted Array | Binary search on the sorted half | Medium | 149 |
| Spiral Matrix | Shrinking boundaries | Medium | 143 |
| Rotting Oranges | Multi-source BFS | Medium | 142 |
| String Compression | Read and write pointers | Medium | 140 |
| Valid Palindrome | Two pointers from both ends | Easy | 137 |
| Merge k Sorted Lists | Min-heap of list heads | Hard | 135 |
| Top K Frequent Elements | Count, then bucket by frequency | Medium | 135 |
| Product of Array Except Self | Prefix and suffix products | Medium | 133 |
| Rotate Image | Transpose, then reverse each row | Medium | 133 |
| Roman to Integer | Compare each symbol with the next | Easy | 133 |
| Course Schedule | Topological sort (Kahn’s algorithm) | Medium | 132 |
| Decode String | Stack for nested structure | Medium | 132 |
| Sliding Window Maximum | Monotonic deque | Hard | 131 |
| Climbing Stairs | 1D dynamic programming | Easy | 130 |
| Merge Sorted Array | Two pointers from the back | Easy | 129 |
| 3Sum | Sort + two pointers | Medium | 128 |
| Median of Two Sorted Arrays | Binary search on a partition | Hard | 127 |
| Basic Calculator II | Running term with deferred addition | Medium | 127 |
| Longest Consecutive Sequence | Hash set, count from run starts | Medium | 126 |
| Word Ladder | Breadth-first search on an implicit graph | Hard | 126 |
| Next Permutation | Rightmost ascent, swap, reverse | Medium | 126 |
| Add Two Numbers | Digit-by-digit addition with a carry | Medium | 125 |
| Longest Common Prefix | Vertical scan | Easy | 124 |
| Letter Combinations of a Phone Number | Backtracking over choices | Medium | 124 |
| Subarray Sum Equals K | Prefix sums + hash map of counts | Medium | 123 |
| Generate Parentheses | Backtracking with constraints | Medium | 123 |
| Coin Change | Bottom-up DP over amounts | Medium | 123 |
| Gas Station | Greedy restart on deficit | Medium | 123 |
| Kth Largest Element in an Array | Quickselect | Medium | 122 |
| Minimum Window Substring | Variable-size sliding window with counts | Hard | 120 |
| Min Stack | Stack with running minimum | Medium | 120 |
| Palindrome Number | Reverse half the digits | Easy | 118 |
| House Robber | 1D dynamic programming | Medium | 118 |
| Basic Calculator | Running sum with a stack of saved contexts | Hard | 118 |
| Word Search | Grid backtracking (DFS) | Medium | 117 |
| Subsets II | Backtracking with duplicate skipping | Medium | 117 |
| Move Zeroes | Read/write two pointers | Easy | 116 |
| All Nodes Distance K in Binary Tree | Tree to graph + BFS | Medium | 116 |
| Add Strings | Digit-by-digit addition with a carry | Easy | 87 |
| Sqrt(x) | Binary search on the answer | Easy | 103 |
| Minimum Array Sum | 0/1 knapsack DP with two budgets | Medium | 87 |
| Meeting Rooms II | Sweep line over start and end events | Medium | 117 |
| Daily Temperatures | Monotonic decreasing stack | Medium | 106 |
| Minimum Path Sum | 2D grid dynamic programming | Medium | 104 |
| Ransom Note | Character frequency counting | Easy | 99 |
| Valid Anagram | Character frequency counting | Easy | 110 |
| Missing Ranges | Linear scan with sentinels | Easy | 116 |
| Isomorphic Strings | Bijection check with two hash maps | Easy | 82 |
| Logger Rate Limiter | Hash map of next allowed time | Easy | 101 |
| Pascal's Triangle | Build each row from the previous row | Easy | 96 |
| Merge Strings Alternately | Two pointers over two sequences | Easy | 102 |
| Reverse Words in a String | Tokenize, then reverse | Medium | 102 |
| Length of Last Word | Scan from the end | Easy | 75 |
| Find the Index of the First Occurrence in a String | String matching with a prefix function (KMP) | Easy | 111 |
| Fraction to Recurring Decimal | Long division with a remainder map | Medium | 90 |
| Remove Duplicates from Sorted Array | Slow/fast two pointers | Easy | 109 |
| Analyze User Website Visit Pattern | Group, enumerate triples, count with a set per user | Medium | 95 |
| Maximum Number of Occurrences of a Substring | Fixed-size sliding window with a frequency map | Medium | 90 |
| Invalid Transactions | Parse, group by key, compare within groups | Medium | 75 |
| Custom Sort String | Counting sort by a custom key | Medium | 74 |
| Accounts Merge | Union-find over shared keys | Medium | 108 |
| Expression Add Operators | Backtracking with a running value | Hard | 99 |
| Combination Sum | Backtracking with a start index | Medium | 111 |
| Maximum Profit in Job Scheduling | Sort by end + DP + binary search | Hard | 99 |
| Sum Root to Leaf Numbers | DFS with a running prefix value | Medium | 89 |
| Closest Binary Search Tree Value | Walk one BST search path | Easy | 89 |
| Minimum Limit of Balls in a Bag | Binary search on the answer | Medium | 95 |
| Subarrays with K Different Integers | Sliding window: exactly k = at most k - at most (k - 1) | Hard | 116 |
| Squares of a Sorted Array | Two pointers from both ends | Easy | 107 |
| Missing Number | Sum or XOR identity | Easy | 85 |
| Maximize Amount After Two Days of Conversions | Graph traversal with multiplied edge weights | Medium | 92 |
| Binary Tree Right Side View | Level-order traversal (BFS by level) | Medium | 93 |
| Word Break II | Backtracking with memoization | Hard | 98 |
| Valid Palindrome II | Two pointers with one branch | Easy | 94 |
| Flood Fill | Grid DFS/BFS over a connected component | Easy | 106 |
| Maximum Matrix Sum | Parity invariant (greedy) | Medium | 92 |
| Word Ladder II | BFS layers + backtracking over a parent DAG | Hard | 97 |
| Counting Bits | DP over bits | Easy | 93 |
| Search Suggestions System | Sort, then binary search each prefix | Medium | 110 |
| Remove All Adjacent Duplicates in String II | Stack of (character, run length) | Medium | 89 |
| Ways to Make a Fair Array | Prefix sums split by parity | Medium | 84 |
| Can Place Flowers | Greedy left-to-right placement | Easy | 86 |
| Longest Arithmetic Subsequence of Given Difference | DP in a hash map keyed by value | Medium | 89 |
| Longest Repeating Character Replacement | Sliding window with a max-frequency count | Medium | 102 |
| Remove All Adjacent Duplicates in String | Stack as the surviving prefix | Easy | 93 |
| Palindrome Linked List | Fast/slow pointers plus in-place reversal | Easy | 95 |
| Find Peak Element | Binary search on the slope | Medium | 102 |
| Check If a Word Occurs As a Prefix of Any Word in a Sentence | Split and check prefixes | Easy | 98 |
Get live help in the real interview
Working solutions in real time during your actual interview. Invisible to screensharing.
Start Free TrialNo credit card required