Question Bank
Every question, one list
Sandboxed coding rounds that run against a hidden test suite, and written questions graded against a rubric — side by side, because when you are drilling a topic you want both.
180 questions · browse by bank instead
- Best Time to Buy and Sell StockWrite `max_profit(prices)` returning the best profit from one buy and one later sell. If no trade is profitable, return `0`. max_profit([7, 1, 5, 3, 6, 4]) -> 5 (buy at 1, sell at 6) maeasyCoderpad#implementation#sliding-window
- Binary SearchWrite `search(nums, target)` returning the index of `target` in the ascending list, or `-1`. search([-1, 0, 3, 5, 9, 12], 9) -> 4 search([-1, 0, 3, 5, 9, 12], 2) -> -1 Everyone knows thieasyCoderpad#binary-search#implementation
- Climbing StairsWrite `climb_stairs(n)` counting the distinct ways to climb `n` steps taking 1 or 2 at a time. climb_stairs(3) -> 3 (1+1+1, 1+2, 2+1) Ways to reach step n is ways(n-1) + ways(n-2) — it is FieasyCoderpad#dp-1d#implementation
- Contains DuplicateWrite `has_duplicate(nums)` that returns `True` when any value appears more than once in the list, and `False` when every value is distinct. has_duplicate([1, 2, 3, 1]) -> True has_duplicateasyCoderpad#arrays-hashing#implementation
- Diameter of Binary TreeWrite `diameter_of_binary_tree(root)` returning the number of edges on the longest path between any two nodes. The path need not pass through the root. [1,2,3,4,5] -> 3 (4 -> 2 -> 1 -> 3) TheasyCoderpad#implementation#trees
- Find a pair summing to a target, in a sorted arrayThe two-pointer pattern in its smallest useful form. The point is not the answer; it is being able to say why the pointers never miss a pair.easyWrittenExplain to unlock#arrays#two-pointers15 min
- Fix: Deduplicate While Preserving OrderYou've inherited a small utility function, `dedupe_preserving_order`, from a teammate. Product just filed a bug: a list of a user's recently-viewed items comes back in a strange, seemingly scrambled oeasyCoderpad#debugging
- Fix: The Page That Skips RowsAn API paginates results with a cursor. Users report that occasionally a record they know exists never appears on any page — and sometimes one appears twice. `paginate(rows, cursor, limit)` returns `easyCoderpad#debugging
- Invert Binary TreeWrite `invert_tree(root)` swapping every left and right child, and returning the root. The code is four lines. What the interviewer is listening for is whether you can name what you are doing — this easyCoderpad#implementation#trees
- Kth Largest Element in a StreamImplement `KthLargest(k, nums)` with `add(val)` returning the kth largest value seen so far. Keeping everything sorted is O(n log n) per add. Keep a *min*-heap of exactly the k largest values insteadeasyCoderpad#heap#implementation
- Last Stone WeightWrite `last_stone_weight(stones)` simulating this: repeatedly take the two heaviest stones and smash them. Equal weights destroy both; otherwise the difference goes back into the pile. Return the lasteasyCoderpad#heap#implementation
- Linked List CycleWrite `has_cycle(head)` returning `True` when the list contains a cycle. A set of visited nodes works and costs O(n) memory. The expected answer is Floyd: a slow pointer moving one step and a fast oneasyCoderpad#implementation#linked-list
- Maximum Depth of Binary TreeWrite `max_depth(root)` returning the number of nodes on the longest path from the root down to a leaf. An empty tree has depth 0. The recursive answer is one line. The reason this is asked at all iseasyCoderpad#implementation#trees
- Merge Booking WindowsA room booking system stores reservations as `(start, end)` minute offsets from midnight. Overlapping and touching reservations should be collapsed into single continuous blocks before they are shown easyCoderpad#implementation
- Merge Two Sorted ListsWrite `merge_two_lists(a, b)` merging two ascending lists into one ascending list and returning its head. Splice the existing nodes rather than allocating new ones. [1,2,4] and [1,3,4] -> [1,1,easyCoderpad#implementation#linked-list
- Number of 1 BitsWrite `hamming_weight(n)` counting the set bits in a non-negative integer. hamming_weight(11) -> 3 (1011) Shifting 32 times works. `n & (n - 1)` clears the lowest set bit, so the loop runs oeasyCoderpad#bit-math#implementation
- Reverse Linked ListWrite `reverse_list(head)` returning the head of the reversed list. 1 -> 2 -> 3 becomes 3 -> 2 -> 1 Save the next node before you overwrite the current pointer, or the rest of the list is goneeasyCoderpad#implementation#linked-list
- Single NumberWrite `single_number(nums)` where every value appears twice except one. Return the one. Use O(1) extra space. single_number([4,1,2,1,2]) -> 4 A hash map solves it in O(n) space, which the conseasyCoderpad#bit-math#implementation
- Subtree of Another TreeWrite `is_subtree(root, sub)` returning `True` when `sub` appears as a subtree of `root` — matching a node and *all* of its descendants exactly. This is two problems: an exact same-tree comparison, aeasyCoderpad#implementation#trees
- Two SumWrite `two_sum(nums, target)` that returns the indices of the two values summing to `target`, as a tuple `(i, j)` with `i < j`. Exactly one such pair exists. two_sum([2, 7, 11, 15], 9) -> (0, 1easyCoderpad#arrays-hashing#implementation
- Valid AnagramWrite `is_anagram(a, b)` that returns `True` when the two strings contain exactly the same characters with the same multiplicities. is_anagram("listen", "silent") -> True is_anagram("rat", easyCoderpad#arrays-hashing#implementation
- Valid PalindromeWrite `is_palindrome(s)` that returns `True` when the string reads the same forwards and backwards, ignoring case and skipping anything that is not a letter or digit. is_palindrome("A man, a planeasyCoderpad#implementation#two-pointers
- Valid ParenthesesWrite `is_valid(s)` returning `True` when every bracket in the string closes in the right order. The string contains only `()[]{}`. is_valid("()[]{}") -> True is_valid("(]") -> False easyCoderpad#implementation#stack
- 3SumWrite `three_sum(nums)` returning every distinct triplet that sums to zero. Each triplet must be sorted ascending, and no triplet may appear twice. Order of the triplets themselves does not matter. mediumCoderpad#implementation#two-pointers
- Auth Middleware Bugroute admin vô tình public.mediumWritten30 min
- Best Time to Buy and Sell Stock with CooldownWrite `max_profit_cooldown(prices)` returning the maximum profit with unlimited transactions, except that you may not buy on the day after you sell. max_profit_cooldown([1,2,3,0,2]) -> 3 (buymediumCoderpad#dp-2d#implementation
- Binary Tree Level Order TraversalWrite `level_order(root)` returning a list of lists, one per level, top to bottom and left to right. [3,9,20,null,null,15,7] -> [[3], [9, 20], [15, 7]] A plain BFS visits nodes in the right ormediumCoderpad#implementation#trees
- Binary Tree Right Side ViewWrite `right_side_view(root)` returning the values visible when looking at the tree from the right, top to bottom. [1,2,3,null,5,null,4] -> [1, 3, 4] Walking down the right spine is the obvioumediumCoderpad#implementation#trees
- Bounded producer-consumer queueCondition variables, and the two mistakes almost everyone makes: waiting without a predicate, and signalling with the lock held.mediumWrittenExplain to unlock#c++#concurrency#condition-variable25 min
- Cheapest Flights Within K StopsWrite `find_cheapest_price(n, flights, src, dst, k)` returning the cheapest price from `src` to `dst` using at most `k` stops, or `-1`. n=3, flights=[[0,1,100],[1,2,100],[0,2,500]], src=0, dst=2,mediumCoderpad#advanced-graphs#implementation
- Circuit BreakerDesign a circuit breaker that protects your service from repeatedly calling a failing downstream dependency. Explain the states it moves through and what triggers each transition.mediumWritten30 min
- Clone GraphWrite `clone_graph(node)` returning a deep copy of a connected undirected graph. Each node has `val` and `neighbors`. The graph has cycles, so a naive traversal never terminates. Keep a map from origmediumCoderpad#graphs#implementation
- Coin ChangeWrite `coin_change(coins, amount)` returning the fewest coins summing to the amount, or `-1` if impossible. Coins may be reused freely. coin_change([1,2,5], 11) -> 3 (5 + 5 + 1) Greedy — alwmediumCoderpad#dp-1d#implementation
- Combination SumWrite `combination_sum(candidates, target)` returning every unique combination of distinct candidates summing to the target. Each candidate may be reused any number of times. Order within and between mediumCoderpad#backtracking#implementation
- Connection PoolExplain why a service uses a connection pool for its database connections instead of opening a new connection for every request, and what happens when a request arrives and the pool is fully checked out.mediumWritten30 min
- Container With Most WaterWrite `max_area(heights)` where `heights[i]` is the height of a vertical line at position `i`. Return the largest area of water any two lines can hold: `min(h[i], h[j]) * (j - i)`. max_area([1, 8mediumCoderpad#implementation#two-pointers
- Copy List with Random PointerEach node has a `next` and a `random` pointer that may target any node or `None`. Write `copy_random_list(head)` returning a deep copy: entirely new nodes, with the same structure. The difficulty is mediumCoderpad#implementation#linked-list
- CORS MysteryPostman chạy nhưng browser fail.mediumWritten30 min
- Course ScheduleWrite `can_finish(num_courses, prerequisites)` returning `True` when every course can be taken. Each pair `[a, b]` means b must be taken before a. This is "does this directed graph have a cycle." A smediumCoderpad#graphs#implementation
- Course Schedule IIWrite `find_order(num_courses, prerequisites)` returning any valid order in which every course can be taken, or `[]` when no order exists. Same graph as Course Schedule, but now you emit the order. WmediumCoderpad#graphs#implementation
- Daily TemperaturesWrite `daily_temperatures(temps)` returning, for each day, how many days you wait for a warmer one. Use `0` when no warmer day follows. daily_temperatures([73,74,75,71,69,72,76,73]) -> [1,1,4,2mediumCoderpad#implementation#stack
- Design a notification serviceDelivery guarantees when every downstream provider is someone else and fails.mediumWrittenExplain to unlock#hld#queues#reliability45 min
- Design a rate limiterSmall surface, deep follow-ups. The distributed counter race is the real question.mediumWrittenExplain to unlock#concurrency#hld#reliability45 min
- Design a retry policyRetries are the most common way a small outage becomes a large one.mediumWritten#distributed-systems#lld#reliability25 min
- Design a text-sharing serviceA warm-up that turns into a storage question the moment you ask where the body lives.mediumWrittenExplain to unlock#caching#hld#storage45 min
- Design a URL shortenerThe read-heavy canonical. Key generation, cache hit rate, and what a 301 costs you.mediumWrittenExplain to unlock#caching#hld#storage45 min
- Design a URL shortenerThe standard opener. Easy to answer adequately, and the follow-ups are where it is actually decided.mediumWritten#caching#storage#system-design45 min
- Design Add and Search WordsImplement `WordDictionary` with `add_word(word)` and `search(word)`, where `.` in a search matches any single character. add_word("bad"); search("b..") -> True Without the wildcard this is a pmediumCoderpad#implementation#tries
- Design an LRU cacheO(1) get and put. Then the follow-up nobody prepares for: make it thread-safe.mediumWrittenExplain to unlock#caching#concurrency#data-structures30 min
- Design notification fan-outPush vs pull, and the celebrity problem that makes the obvious answer fail.mediumWritten#fan-out#queues#system-design40 min
- Design search autocompleteLatency is the requirement, so almost everything must be precomputed.mediumWrittenExplain to unlock#caching#data-structures#hld45 min
- Edit DistanceWrite `min_distance(a, b)` returning the fewest single-character insertions, deletions or replacements that turn `a` into `b`. min_distance("horse", "ros") -> 3 On a match, carry the diagonal mediumCoderpad#dp-2d#implementation
- Encode and Decode StringsImplement `encode(strings)` and `decode(text)` so that `decode(encode(xs)) == xs` for any list of strings, including empty strings and strings containing any character at all. encode(["hi", "thermediumCoderpad#arrays-hashing#implementation
- Evaluate Reverse Polish NotationWrite `eval_rpn(tokens)` evaluating a list of tokens in postfix notation. Tokens are integers as strings, or one of `+ - * /`. Division truncates toward zero. eval_rpn(["2", "1", "+", "3", "*"]) mediumCoderpad#implementation#stack
- Find Minimum in Rotated Sorted ArrayWrite `find_min(nums)` returning the smallest value in an ascending array that has been rotated an unknown number of times. All values are distinct. find_min([3, 4, 5, 1, 2]) -> 1 find_min(mediumCoderpad#binary-search#implementation
- Find the gapsGaps and islands. Once you have seen the trick it is easy, and the trick is worth knowing.mediumWritten#gaps-and-islands#sql#window-functions20 min
- Fix: The Invoice That Does Not BalanceAn invoicing service splits a total across several line items and then verifies the parts sum back to the whole. It fails intermittently in production with "invoice does not balance", and nobody can rmediumCoderpad#debugging
- Flaky Clock Testremove dependency vào current time.mediumWritten30 min
- Gas StationWrite `can_complete_circuit(gas, cost)` returning the starting index from which you can drive the whole circle, or `-1`. You start with an empty tank. gas = [1,2,3,4,5], cost = [3,4,5,1,2] -> 3mediumCoderpad#greedy#implementation
- Graph Valid TreeWrite `valid_tree(n, edges)` returning `True` when the undirected graph on `n` nodes is a tree: connected and acyclic. valid_tree(5, [[0,1],[0,2],[0,3],[1,4]]) -> True Two conditions, and bothmediumCoderpad#graphs#implementation
- Group AnagramsWrite `group_anagrams(words)` that groups the input into lists of mutual anagrams. Return a list of groups; order within a group and between groups does not matter. group_anagrams(["eat", "tea", mediumCoderpad#arrays-hashing#implementation
- House RobberWrite `rob(nums)` returning the largest sum obtainable from a list with no two chosen elements adjacent. rob([2,7,9,3,1]) -> 12 (2 + 9 + 1) At each house you either take it and add the best mediumCoderpad#dp-1d#implementation
- House Robber IIWrite `rob_circular(nums)` with the same rule as House Robber, except the first and last houses are adjacent. rob_circular([2,3,2]) -> 3 (cannot take both 2s) The circle only forbids one commediumCoderpad#dp-1d#implementation
- Idempotent Payment APIretry không tạo hai payment.mediumWritten30 min
- Implement TrieImplement `Trie` with `insert(word)`, `search(word)` returning whether the exact word was inserted, and `starts_with(prefix)`. The one thing that separates a working trie from a broken one is markingmediumCoderpad#implementation#tries
- Index Zero Doesn't Existsearch tìm thấy item ở index 0 nhưng code báo "not found".mediumWritten30 min
- Infinite Retryretry loop không increment counter trong một branch.mediumWritten30 min
- Insert IntervalWrite `insert_interval(intervals, new_interval)` inserting into a list of non-overlapping intervals sorted by start, merging where necessary, and returning the result sorted. insert([[1,3],[6,9]]mediumCoderpad#implementation#intervals
- Jump GameWrite `can_jump(nums)` where each value is the maximum jump length from that index. Return `True` if the last index is reachable from index 0. can_jump([2,3,1,1,4]) -> True can_jump([3,2,1,mediumCoderpad#greedy#implementation
- Jump Game IIWrite `min_jumps(nums)` returning the fewest jumps to reach the last index. The last index is always reachable. min_jumps([2,3,1,1,4]) -> 2 Think of it as BFS over ranges: everything reachablemediumCoderpad#greedy#implementation
- K Closest Points to OriginWrite `k_closest(points, k)` returning the k points closest to the origin, in any order. Each point is a two-element list. k_closest([[1,3],[-2,2]], 1) -> [[-2,2]] Never call `sqrt`: it costs mediumCoderpad#heap#implementation
- Koko Eating BananasWrite `min_eating_speed(piles, h)` returning the smallest integer speed `k` such that eating `k` bananas per hour finishes every pile within `h` hours. A pile takes `ceil(pile / k)` hours and a partiamediumCoderpad#binary-search#implementation
- Kth Largest Element in an ArrayWrite `find_kth_largest(nums, k)` returning the kth largest value (1-indexed). Duplicates count separately, so in `[3,3,1]` the 2nd largest is `3`. Sorting is O(n log n) and a size-k heap is O(n log mediumCoderpad#heap#implementation
- Kth largest in a streamA min-heap of size k. The counter-intuitive part is that you keep the *smallest* elements at the top.mediumWritten#heap#streaming#top-k20 min
- Kth Largest in a StreamValues arrive one at a time and never stop. After each arrival, report the kth largest value seen so far. Implement a `KthLargest` class: - `KthLargest(k)` — construct for a fixed k. - `add(value)` mediumCoderpad#implementation
- Kth Smallest Element in a BSTWrite `kth_smallest(root, k)` returning the kth smallest value (1-indexed) in the BST. An in-order traversal of a BST visits values in ascending order, so this is "stop after k visits." Collecting evmediumCoderpad#implementation#trees
- Last Item Missingpagination không bao giờ trả item cuối cùng.mediumWritten30 min
- Longest Common SubsequenceWrite `longest_common_subsequence(a, b)` returning the length of the longest subsequence present in both strings. Subsequences need not be contiguous. longest_common_subsequence("abcde", "ace") mediumCoderpad#dp-2d#implementation
- Longest Consecutive SequenceWrite `longest_consecutive(nums)` returning the length of the longest run of consecutive integers present in the list. The values are unsorted and may repeat. longest_consecutive([100, 4, 200, 1,mediumCoderpad#arrays-hashing#implementation
- Longest Increasing SubsequenceWrite `length_of_lis(nums)` returning the length of the longest strictly increasing subsequence. Elements need not be contiguous. length_of_lis([10,9,2,5,3,7,101,18]) -> 4 (2,3,7,101) The O(mediumCoderpad#dp-1d#implementation
- Longest Palindromic SubstringWrite `longest_palindrome(s)` returning the longest palindromic substring. Any one will do if several tie. longest_palindrome("babad") -> "bab" or "aba" longest_palindrome("cbbd") -> "bbmediumCoderpad#dp-1d#implementation
- Longest Repeating Character ReplacementWrite `character_replacement(s, k)` returning the length of the longest substring that can be made of one repeated character by replacing at most `k` characters. character_replacement("AABABBA", mediumCoderpad#implementation#sliding-window
- Longest run of distinct elementsSliding window with a "last seen" map. The trap is the pointer that moves backwards.mediumWrittenExplain to unlock#hash-map#sliding-window#strings25 min
- Longest Substring Without Repeating CharactersWrite `length_of_longest_substring(s)` returning the length of the longest run of characters with no repeats. length_of_longest_substring("abcabcbb") -> 3 ("abc") length_of_longest_substrmediumCoderpad#implementation#sliding-window
- Lowest Common Ancestor of a BSTWrite `lowest_common_ancestor(root, p, q)` returning the deepest node that is an ancestor of both. Nodes are node objects, both present in the tree, and a node counts as its own ancestor. In a generamediumCoderpad#implementation#trees
- LRU CacheImplement `LRUCache(capacity)` with `get(key)` returning the value or `-1`, and `put(key, value)`. When the cache is full, evict the least recently used entry. Both operations must be O(1). Neither smediumCoderpad#implementation#linked-list
- LRU CacheDesign an LRU (Least Recently Used) cache with O(1) get and put operations. Explain the data structures you'd use and why, and what happens on a cache hit vs. a cache miss when the cache is full.mediumWritten30 min
- Max Area of IslandWrite `max_area_of_island(grid)` returning the number of cells in the largest connected group of `1`s, or `0` when there is no land. The grid holds integers. Identical traversal to Number of Islands mediumCoderpad#graphs#implementation
- Maximum Product SubarrayWrite `max_product(nums)` returning the largest product of any contiguous non-empty subarray. max_product([2,3,-2,4]) -> 6 max_product([-2,0,-1]) -> 0 Kadane on sums does not transfermediumCoderpad#dp-1d#implementation
- Maximum SubarrayWrite `max_subarray(nums)` returning the largest sum of any contiguous non-empty subarray. max_subarray([-2,1,-3,4,-1,2,1,-5,4]) -> 6 (4,-1,2,1) Kadane in one line of reasoning: the best submediumCoderpad#greedy#implementation
- Meeting Rooms IIWrite `min_meeting_rooms(intervals)` returning the fewest rooms needed so no two overlapping meetings share one. A meeting ending exactly when another starts can reuse the room. [[0,30],[5,10],[1mediumCoderpad#implementation#intervals
- Merge IntervalsWrite `merge_intervals(intervals)` merging all overlapping intervals and returning the result sorted by start. [[1,3],[2,6],[8,10],[15,18]] -> [[1,6],[8,10],[15,18]] Sort by start, then walk: mediumCoderpad#implementation#intervals
- Merge overlapping intervalsSorting by start, then one pass. Most of the marks are in how you define "overlapping".mediumWritten#greedy#intervals#sorting20 min
- Min StackImplement a `MinStack` class with `push(x)`, `pop()`, `top()` and `get_min()`, all in O(1). Scanning for the minimum on demand is O(n) and defeats the exercise. Keep a second stack of minima alongsidmediumCoderpad#implementation#stack
- Mocking Too Muchtest xanh nhưng production hỏng.mediumWritten30 min
- Mutable Default Nightmarehai users vô tình share cùng một Python list.mediumWritten30 min
- N+1 Profile Page101 queries cho 100 users.mediumWritten30 min
- Network Delay TimeWrite `network_delay_time(times, n, k)` where each `[u, v, w]` is a directed edge with delay `w`, nodes are `1..n`, and the signal starts at `k`. Return the time for all nodes to receive it, or `-1` imediumCoderpad#advanced-graphs#implementation
- Non-overlapping IntervalsWrite `erase_overlap_intervals(intervals)` returning the minimum number of intervals to remove so the rest do not overlap. Intervals that merely touch do not overlap. [[1,2],[2,3],[3,4],[1,3]] -mediumCoderpad#implementation#intervals
- Number of IslandsWrite `num_islands(grid)` counting connected groups of `"1"` cells in a grid of `"1"` and `"0"`. Cells connect up, down, left and right — not diagonally. Scan for an unvisited land cell, count it, thmediumCoderpad#graphs#implementation
- Pacific Atlantic Water FlowWrite `pacific_atlantic(heights)` returning every cell from which water can reach both oceans. Water flows to a neighbour of equal or lower height. The Pacific touches the top and left edges, the AtlamediumCoderpad#graphs#implementation
- Palindrome PartitioningWrite `partition(s)` returning every way to cut the string so that every piece is a palindrome. partition("aab") -> [["a","a","b"], ["aa","b"]] Generating all 2^(n-1) partitions and filtering mediumCoderpad#backtracking#implementation
- Permutation in StringWrite `contains_permutation(pattern, text)` returning `True` when any permutation of `pattern` appears as a contiguous substring of `text`. contains_permutation("ab", "eidbaooo") -> True ("bmediumCoderpad#implementation#sliding-window
- PermutationsWrite `permutations(nums)` returning every ordering of a list of distinct integers, in any order. permutations([1,2,3]) -> 6 orderings Unlike Subsets there is no start index: every unused elemmediumCoderpad#backtracking#implementation
- Priority Job QueueDesign a job queue where higher-priority jobs are processed before lower-priority ones, even if the lower-priority jobs were submitted first. Explain the data structure you'd use and how priority is used.mediumWritten30 min
- Product of Array Except SelfWrite `product_except_self(nums)` returning a list where each position holds the product of every other element. product_except_self([1, 2, 3, 4]) -> [24, 12, 8, 6] Division is banned, and themediumCoderpad#arrays-hashing#implementation
- Remove Nth Node From End of ListWrite `remove_nth_from_end(head, n)` removing the nth node counted from the end, and returning the head. [1,2,3,4,5], n = 2 -> [1,2,3,5] Counting the length first and walking again is two passmediumCoderpad#implementation#linked-list
- Reorder ListWrite `reorder_list(head)` reordering the list in place to `first, last, second, second-last, ...`. Return nothing; modify the nodes. [1,2,3,4] -> [1,4,2,3] [1,2,3,4,5] -> [1,5,2,4,3] mediumCoderpad#implementation#linked-list
- Retry with Exponential Backoff + JitterExplain why a retry mechanism should use exponential backoff with jitter instead of retrying immediately or at a fixed interval, especially when many clients might be retrying the same failing dependency at once.mediumWritten30 min
- Rolling MaximumA monitoring dashboard shows the highest value seen in the last `k` samples, updated on every new sample. Implement `rolling_max(values, k)`, returning a list of the maximum of every contiguous windomediumCoderpad#implementation
- Rotting OrangesWrite `oranges_rotting(grid)` where `0` is empty, `1` is fresh and `2` is rotten. Each minute, rot spreads to fresh neighbours. Return the minutes until none are fresh, or `-1` if some can never rot. mediumCoderpad#graphs#implementation
- Running total per accountWindow functions. The frame clause is the part people get wrong without noticing.mediumWritten#sql#window-functions20 min
- Search a 2D MatrixWrite `search_matrix(matrix, target)` returning `True` if the value is present. Each row is sorted ascending, and the first value of a row is greater than the last value of the row above. search_mediumCoderpad#binary-search#implementation
- Search a rotated sorted arrayBinary search where one half is always still sorted. Finding which half is the entire question.mediumWrittenExplain to unlock#arrays#binary-search25 min
- Search in Rotated Sorted ArrayWrite `search_rotated(nums, target)` returning the index of the target in a rotated ascending array of distinct values, or `-1`. search_rotated([4, 5, 6, 7, 0, 1, 2], 0) -> 4 search_rotatedmediumCoderpad#binary-search#implementation
- SubsetsWrite `subsets(nums)` returning every subset of a list of distinct integers. Order does not matter, but no subset may repeat. subsets([1,2,3]) -> 8 subsets, including [] and [1,2,3] At each inmediumCoderpad#backtracking#implementation
- Sum of Two IntegersWrite `get_sum(a, b)` returning `a + b` without using `+` or `-`. Inputs may be negative and fit in 32 bits. XOR gives the addition with every carry dropped; `(a & b) << 1` gives exactly those carriemediumCoderpad#bit-math#implementation
- Suppress Duplicate AlertsAn alerting pipeline fires the same alert repeatedly while a condition persists. You need to suppress duplicates: an alert with a given key should only pass through if that key has not been seen in thmediumCoderpad#implementation
- Surrounded RegionsWrite `solve(board)` flipping every `"O"` region fully surrounded by `"X"` into `"X"`, modifying the board in place. A region touching the border is not surrounded. [["X","X","X"],["X","O","X"],[mediumCoderpad#graphs#implementation
- Take-home: a rate-limited APIFour hours. The brief is under-specified on purpose — decide, and write down why.mediumWritten#api-design#rate-limiting#take-home240 min
- Target SumWrite `find_target_sum_ways(nums, target)` counting the ways to put a `+` or `-` in front of each number so the expression equals the target. find_target_sum_ways([1,1,1,1,1], 3) -> 5 Brute fomediumCoderpad#dp-2d#implementation
- Tell me about a time you broke productionThe failure story. Candidates sabotage this one by picking a failure that was not really theirs.mediumWritten#behavioral#failure#ownership30 min
- Tell me about a time you disagreed with a decisionTests whether you can disagree without being difficult, and commit without being a pushover.mediumWritten#behavioral#conflict#star30 min
- Tell me about the most ambiguous problem you have worked onTests whether you can make progress without being told what to do.mediumWritten#ambiguity#behavioral#star30 min
- The Exception Nobody Seescatch quá rộng rồi swallow error.mediumWritten30 min
- The loop that should be fast and is notSumming a matrix column-by-column instead of row-by-row. A test of whether you think about memory at all.mediumWrittenExplain to unlock#c++#cache#memory20 min
- The Missing CustomersINNER JOIN làm biến mất customer chưa có order.mediumWritten30 min
- The Stale CacheDB update thành công nhưng cache vẫn trả object cũ.mediumWritten30 min
- The stale closureAn interval that always logs 0. The most common React bug, and a good test of whether you understand renders or just hooks.mediumWritten#closures#javascript#react20 min
- Thread-Safe CounterImplement a `ThreadSafeCounter` class with two methods: - `increment()` — increments the counter by 1. - `value()` — returns the current count. Multiple threads will call `increment()` concurrently.mediumCoderpad#implementation
- Token Bucket Rate LimiterDesign a token bucket rate limiter that allows an average of N requests per second but tolerates short bursts. Explain how tokens are added and consumed, and what happens when a request arrives with no tokens available.mediumWritten30 min
- Top K Frequent ElementsWrite `top_k_frequent(nums, k)` returning the `k` most frequent values, in any order. top_k_frequent([1, 1, 1, 2, 2, 3], 2) -> [1, 2] Sorting by count is O(n log n) and a size-k heap is O(n lomediumCoderpad#arrays-hashing#implementation
- Two Sum II — Sorted InputWrite `two_sum_sorted(nums, target)` where `nums` is sorted ascending. Return the 0-based indices `(i, j)` with `i < j` of the two values summing to `target`. Exactly one answer exists. Use O(1) extramediumCoderpad#implementation#two-pointers
- Unique PathsWrite `unique_paths(m, n)` counting the routes from the top-left to the bottom-right of an m x n grid moving only right or down. unique_paths(3, 7) -> 28 Each cell is the sum of the cell abovemediumCoderpad#dp-2d#implementation
- Users Who Never Logged Inanti-join đúng cách.mediumWritten30 min
- Valid SudokuWrite `is_valid_sudoku(board)` for a 9x9 board given as a list of 9 lists of single-character strings, where `"."` marks an empty cell. Return `True` if no row, column, or 3x3 box contains a repeated mediumCoderpad#arrays-hashing#implementation
- Validate Binary Search TreeWrite `is_valid_bst(root)` returning `True` when every node in the left subtree is strictly less than the node, and every node in the right subtree is strictly greater — for *all* nodes, not just immemediumCoderpad#implementation#trees
- Versioning an API you cannot take downThe right answer starts by questioning whether you need a new version at all.mediumWritten#api-design#rest#versioning25 min
- What does idempotent actually mean?Everyone can list which verbs are idempotent. Far fewer can make a payment endpoint safe to retry.mediumWrittenExplain to unlock#api-design#reliability#rest20 min
- When is an atomic not enough?Everyone can say "an atomic is lock-free and cheaper". The question is what a mutex gives you that a pile of atomics does not.mediumWrittenExplain to unlock#atomics#c++#concurrency15 min
- Why did my counter get slower with more threads?Eight threads, eight separate counters, no locks — and throughput falls off a cliff. This is the question that finds out whether you know what a cache line is.mediumWrittenExplain to unlock#c++#cache#concurrency20 min
- Word BreakWrite `word_break(s, word_dict)` returning `True` when the string can be split into a sequence of dictionary words. Words may be reused. word_break("leetcode", ["leet","code"]) -> True Greedy mediumCoderpad#dp-1d#implementation
- Word SearchWrite `exist(board, word)` returning `True` when the word can be spelt by walking adjacent cells (up, down, left, right) without reusing a cell. The whole problem is the visited bookkeeping. OverwritmediumCoderpad#backtracking#implementation
- Alien DictionaryWrite `alien_order(words)` returning a letter order consistent with the given sorted word list, or `""` if none exists. Any valid order is accepted. ["wrt","wrf","er","ett","rftt"] -> "wertf" hardCoderpad#advanced-graphs#implementation
- Binary Tree Maximum Path SumWrite `max_path_sum(root)` returning the largest sum along any path between two nodes. The path follows parent-child edges, need not touch the root, and must contain at least one node. Values may be nhardCoderpad#implementation#trees
- Design a chat serviceConnection state is the real problem, and ordering is per-conversation, never global.hardWrittenExplain to unlock#consistency#distributed-systems#hld45 min
- Design a collaborative document editorThe hardest consistency question on the list. OT versus CRDT, honestly.hardWrittenExplain to unlock#consistency#distributed-systems#hld45 min
- Design a distributed job schedulerLeader election and at-least-once done properly, with dependencies.hardWrittenExplain to unlock#distributed-systems#hld#reliability45 min
- Design a distributed key-value storeThe question that tests whether you know CAP for real rather than as a slogan.hardWrittenExplain to unlock#consistency#distributed-systems#hld45 min
- Design a distributed rate limiterChoosing the algorithm is half of it. The other half is what happens when the limiter itself fails.hardWritten#distributed-systems#rate-limiting#system-design45 min
- Design a file sync serviceBandwidth is the constraint, and two offline devices editing the same file is the hard case.hardWrittenExplain to unlock#consistency#hld#storage45 min
- Design a limit order bookThe canonical quant LLD question. Choosing the data structure is where it is won or lost.hardWrittenExplain to unlock#data-structures#lld#low-latency45 min
- Design a market data distribution systemWhere the usual system-design answers stop working: microseconds matter, and dropping data can be correct.hardWritten#lock-free#low-latency#market-data50 min
- Design a metrics and monitoring systemWrite-heavy, and cardinality is what actually kills these systems.hardWrittenExplain to unlock#hld#reliability#storage45 min
- Design a news feedThe fanout question, and the most-asked design round in the industry.hardWrittenExplain to unlock#caching#distributed-systems#hld45 min
- Design a payment system and ledgerCorrectness over throughput. Money makes every shortcut visible.hardWrittenExplain to unlock#consistency#hld#reliability45 min
- Design a post and follow-graph serviceFeed seen from the write path: id generation, the follow graph, and hot keys.hardWrittenExplain to unlock#consistency#distributed-systems#hld45 min
- Design a ride-matching serviceGeospatial search plus a very high write rate of location updates.hardWrittenExplain to unlock#distributed-systems#hld#storage45 min
- Design a ticket booking systemInventory correctness under a thundering herd. Overselling is the failure to design against.hardWrittenExplain to unlock#concurrency#consistency#hld45 min
- Design a video streaming serviceA job pipeline wearing a product costume, plus the economics of delivery.hardWrittenExplain to unlock#caching#hld#queues45 min
- Design a web crawlerThe politeness question. Dedup at billions of URLs is where the naive answer breaks.hardWrittenExplain to unlock#distributed-systems#hld#storage45 min
- Design an ad click aggregation pipelineThe streaming-correctness question. Late events and duplicates decide the round.hardWrittenExplain to unlock#consistency#hld#queues45 min
- Design an object storage serviceDurability arithmetic, and the metadata service that is the real bottleneck.hardWrittenExplain to unlock#hld#reliability#storage45 min
- Fewest machines to finish by a deadlineBinary search on the answer. Recognising that the question is monotonic is the whole insight.hardWrittenExplain to unlock#binary-search#greedy#optimisation30 min
- Find Median from Data StreamImplement `MedianFinder` with `add_num(num)` and `find_median()` returning the median of everything added so far, as a float. Keep a max-heap of the lower half and a min-heap of the upper half. Fix ahardCoderpad#heap#implementation
- Largest Rectangle in HistogramWrite `largest_rectangle_area(heights)` returning the area of the largest rectangle that fits under the histogram. largest_rectangle_area([2, 1, 5, 6, 2, 3]) -> 10 (heights 5 and 6, width 2) hardCoderpad#implementation#stack
- Median of Two Sorted ArraysWrite `find_median_sorted_arrays(a, b)` returning the median of the two ascending arrays combined, as a float. find_median_sorted_arrays([1, 3], [2]) -> 2.0 find_median_sorted_arrays([1,hardCoderpad#binary-search#implementation
- Merge k Sorted ListsWrite `merge_k_lists(lists)` merging `k` ascending linked lists into one and returning its head. The input may contain empty lists. Merging them one at a time into an accumulator is O(n k) — say so, hardCoderpad#implementation#linked-list
- Minimum Window SubstringWrite `min_window(s, t)` returning the shortest substring of `s` containing every character of `t` including duplicates. Return `""` when no such window exists. min_window("ADOBECODEBANC", "ABC")hardCoderpad#implementation#sliding-window
- N-QueensWrite `solve_n_queens(n)` returning every board on which `n` queens share no row, column, or diagonal. Each board is a list of `n` strings using `Q` and `.`. Place one queen per row, so rows never cohardCoderpad#backtracking#implementation
- Serialize and Deserialize Binary TreeImplement `serialize(root)` returning a string, and `deserialize(data)` rebuilding the tree, so that the round trip preserves the tree exactly. Pre-order with an explicit marker for every missing chihardCoderpad#implementation#trees
- Sliding Window MaximumWrite `max_sliding_window(nums, k)` returning the maximum of every contiguous window of width `k`, left to right. max_sliding_window([1,3,-1,-3,5,3,6,7], 3) -> [3, 3, 5, 5, 6, 7] A heap gives hardCoderpad#implementation#sliding-window
- Take-home: trade reconciliationTwo files that should agree and do not. A quant-flavoured brief where the edge cases are the whole exercise.hardWritten#correctness#data#take-home300 min
- The ABA problemYour compare-and-swap succeeded. That does not mean nothing happened.hardWrittenExplain to unlock#atomics#c++#concurrency25 min
- Trapping Rain WaterWrite `trap(heights)` returning the total units of water trapped between the bars after rain. trap([0,1,0,2,1,0,1,3,2,1,2,1]) -> 6 Water above any bar is `min(max_left, max_right) - height`. PhardCoderpad#implementation#two-pointers
- Was double-checked locking ever actually broken?A famous bug, a famous fix, and a much simpler answer almost nobody gives.hardWrittenExplain to unlock#c++#concurrency#memory-model20 min
- What does memory_order_relaxed actually guarantee?The question that separates people who have used atomics from people who understand them.hardWrittenExplain to unlock#atomics#c++#concurrency25 min
- What is the hardest technical problem you have solved?Half behavioral, half technical depth. The follow-ups go deep, so pick something you genuinely understand.hardWritten#behavioral#star#technical-depth30 min
- Why is this query slow?An index exists and is not being used. This question is about whether you read plans or guess.hardWritten#indexing#performance#query-planning30 min
- Word Search IIWrite `find_words(board, words)` returning every word from the list that can be spelt by walking adjacent cells (up, down, left, right) without reusing a cell in a single word. Return them in any ordehardCoderpad#implementation#tries