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.
Topicimplementation (105)system-design (24)hld (20)trees (11)distributed-systems (10)arrays-hashing (9)concurrency (9)graphs (9)binary-search (8)consistency (8)dp-1d (8)linked-list (8)reliability (8)storage (8)
Clear filters120 questions · browse by bank instead
- 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 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
- 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
- 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