Skip to content
Tech Interview Prep

Top 100 Software Development Engineer (SDE) Practice MCQs

Every question on one page: open one, choose an answer, and see why at once. Signed in, your latest answer to each question counts, and you can answer again after 24 hours.

Curated: · Written: · Reviewed:

Reviewed 85Review pending 15

Answers to reviewed questions count toward this role and the overall leaderboard; your latest answer to each one is the one that counts.

100 questions · Flow follows Relevance until this set has a learning order.

MCQ-1A service must return the indices of two entries in an array of 10^6 int32 values that sum to a target. The array is read-only and stored in place, using 4 MB of a 12 MB working-memory limit, and each request has a 2-second latency budget. Which approach fits the limit and the budget?
Difficulty: Hard
MCQ-2A sliding window over a lowercase string keeps an array freq of 26 letter counts for the window s[2..5]. The left pointer moves from index 2 to index 3, so s[2] leaves the window. Which update keeps freq correct for the new window?
Difficulty: Easy
MCQ-3A template engine parses `f(a[1 + g(2], 3)` with an explicit stack: each opener is pushed, and each closer pops once and checks that the popped kind matches. A colleague's draft instead keeps only a depth counter that goes up on openers and down on closers. Which behavior does the stack parser show on this input, and where?
Difficulty: Medium
MCQ-4A 100,000-entry LRU cache uses a hash map and a doubly linked list for O(1) `get` and `put`, and many threads call `get` at once. Which change keeps each operation O(1) and makes the structure safe under concurrent access?
Difficulty: Medium
MCQ-5A Java service counts connected components in an undirected graph of 10^6 nodes stored as adjacency lists, running on a worker thread with a 512 KB stack. The largest production input is one long path, 1-2-3 through 1000000, so a depth-first walk reaches depth 10^6. Which traversal overflows the stack on this input?
Difficulty: Easy
MCQ-6A monorepo build reports a dependency cycle among six packages. Read as X depends on Y, the edges are: app on ui, ui on core, core on util, util on core, util on fmt. fmt depends on nothing. Which algorithm returns exactly the packages in the cycle?
Difficulty: Medium
MCQ-7A routing graph has 2,000 routers and 10,000 directed links, and 300 of those links carry negative cost as prepaid transit credits. The service must return the cheapest route from one source router to every other router, and the graph has no negative cycle. Which algorithm stays correct for this request, and what does it cost?
Difficulty: Medium
MCQ-8A spell-check autocomplete service loads a dictionary of 10^5 words once and answers many prefix queries, and the team's requirement is that each query's cost depends only on the prefix length, not on how many words the dictionary holds. Which structure meets that requirement?
Difficulty: Medium
MCQ-9A service builds every bundle of 20 catalogue items from a list where some SKUs appear two or three times, and each bundle may use no more copies than are stocked. Plain recursive generation prints the same bundle several times. Which step removes the repeated bundles while keeping bundles that legitimately take two copies of one SKU?
Difficulty: Medium
MCQ-10A checkout service counts the ways to pay exactly 5 cents from unlimited coins of 1, 2 and 5 cents, where two payments that differ only in order count once. The DP table is filled with nested `for` loops, and the team must choose the nesting that counts combinations rather than sequences. Which loop order returns the correct count?
Difficulty: Medium
MCQ-11A telemetry job must report the length of the longest strictly increasing subsequence of 100,000 sensor readings, which are arbitrary integers kept in arrival order. The C++17 service has a 1-second limit on one core, and the readings must keep their original order. Which approach meets the limit?
Difficulty: Easy
MCQ-12A spell-check service computes the edit distance between two strings of length 5000 with the standard DP, where each cell depends only on the cell above, the cell to the left and the cell diagonally up-left. The service returns only the final distance and never prints an alignment, but a full table of int cells takes about 100 MB. Which memory change fits?
Difficulty: Easy
MCQ-13A robot moves only right or down on a 3-row by 4-column grid, from the top-left cell to the bottom-right cell. Cell (0,2) is an obstacle and no other cell is blocked. The DP table `dp[i][j] = dp[i-1][j] + dp[i][j-1]`, with blocked cells set to 0, is seeded by filling the first row and first column before the rest. How many distinct routes reach the bottom-right corner?
Difficulty: Medium
MCQ-14A delivery robot starts at cell 0 of a row of 5 cells. Cell i has jump limit `nums[i]`, so it may move forward 1 to `nums[i]` cells from there. The limits are `[3,2,1,0,4]`. Scanning left to right and tracking the furthest reachable cell, what does the scan conclude?
Difficulty: Medium
MCQ-15A depot ships parcels weighing 4, 8, 2, 7, 5 and 3 kg in that fixed order, using trucks that carry at most C kg a day, and 3 days must suffice. Feasibility is monotone in C, so the team binary searches for the minimum C. After earlier probes lo is 8 (heaviest parcel) and hi is 13, which is feasible. The probe mid = 10 needs 4 days, so it is infeasible. Which update keeps the search invariant?
Difficulty: Medium
MCQ-16A search routine looks for a target in a sorted array that was rotated at an unknown pivot, and the values may repeat. Each probe compares `nums[mid]` with `nums[hi]` to find which half is sorted. What is the worst-case running time of this search in terms of n?
Difficulty: Easy
MCQ-17A Java service reverses a singly linked list in place with a loop that does `next = cur.next; cur.next = prev; prev = cur; cur = next;` but the team's first draft put `cur = cur.next` at the end, after `cur.next = prev`. The list is 1 -> 2 -> 3, head is node 1, and the loop starts with prev = null and cur = head. Under the draft's order, what does the list look like after the first iteration?
Difficulty: Medium
MCQ-18A singly linked list has 10 nodes indexed 0 to 9 from the head, and the last node (index 9) links back to node index 4. Slow moves one node per step and fast moves two from the head, and they first meet at a node. The team then resets slow to the head and advances both pointers one node per step until they meet again. Where do they meet on this second meeting?
Difficulty: Easy
MCQ-19A batch job merges 256 sorted run files totalling 4 GB of 128-byte records into one sorted output. The job has a 64 MB memory budget, keeps one heap entry per run and an 8 MB output buffer, and must read each run file exactly once. Which plan fits the budget?
Difficulty: Hard
MCQ-20A service uses quickselect to return the k-th smallest of n integers. The input order is chosen by an adversary, and the team needs expected linear time on every input. Which pivot rule gives that guarantee?
Difficulty: Easy
MCQ-21A Java service runs a level-order traversal with one ArrayDeque, enqueuing each node's children when that node is dequeued. Depth 5 of the tree holds 1,000 nodes, and when the walk reaches depth 5 the deque holds exactly those 1,000 nodes. In left-to-right order the leftmost 400 of them each have 2 children and the other 600 are leaves. Depth 6 has 800 nodes. What is the largest number of nodes the deque holds while the depth-5 nodes are being dequeued?
Difficulty: Medium
MCQ-22A binary search tree with distinct keys has root 50, left child 30 (whose children are 20 and 40) and right child 70. A lookup service must find the lowest common ancestor of keys 20 and 40 by walking down from the root, with no parent pointers. The walk has already passed the root, where both keys are smaller, and reached node 30. Which node should it return?
Difficulty: Easy
MCQ-23A Java service validates that a binary search tree of 32-bit int values is ordered by passing each node's lower and upper bounds down the recursion. The root holds 2147483647 and its right child holds 5, which must be rejected. A colleague proposes tightening the bounds to node.val + 1 and node.val - 1 in int arithmetic. Which bound handling rejects this tree without overflow?
Difficulty: Medium
MCQ-24A binary tree of 10^5 nodes shaped as one long left-leaning chain must be saved to a string and restored on a worker thread with a small stack, so the restore cannot recurse. Which traversal order writes the tree with null markers so that a queue-based reader can rebuild it?
Difficulty: Easy
MCQ-25A 0/1 knapsack keeps one array `dp`, where `dp[c]` is the best value within capacity c, all zeros at the start. Its only item has weight 2 and value 3 and the capacity is 4, while the production service runs 200 items at capacity 10^4 with one pass per item. Which capacity loop direction keeps the item used at most once, and what is `dp[4]` afterwards?
Difficulty: Easy
MCQ-26A C++17 service loads an undirected graph with 10^6 nodes and 2 x 10^6 edges for breadth-first search over each node's neighbours, and the whole structure must stay within 24 MB of heap. Which storage fits that budget?
Difficulty: Medium
MCQ-27A build planner orders seven tasks with Kahn's algorithm. The edges are fetch to gen, gen to compile, compile to link, link to compile, link to test, test to release, and fetch to docs, where each arrow means the left task must finish first. The queue empties after the scheduled tasks run. Which tasks are left unscheduled?
Difficulty: Medium
MCQ-28A logistics team has 4,000 depots, and pairwise link costs are stored as a dense 4,000 by 4,000 matrix with no edge list. They need one minimum spanning tree per run, and profiling shows that sorting the roughly 8 million edges dominates the time. Which algorithm avoids that sort and has the lowest worst-case running time on this input?
Difficulty: Medium
MCQ-29A metrics job reads 10^7 integer samples and reports the maximum of every window of 3 consecutive samples with a monotonic deque of indices. The samples begin 1, 3, -1, -3, 5, 3, 6, 7. After index 5 is processed, what do the deque contents and the reported window maximum hold?
Difficulty: Medium
MCQ-30A metrics service keeps 500,000 int64 request counters, one per endpoint ID, in an 8 MB memory limit. Each second it applies about 20,000 point increments and answers about 20,000 range sums over contiguous ID ranges, with no ranges precomputed. Which structure answers both operations in O(log n) within that memory?
Difficulty: Easy
MCQ-31A room booking service must host the largest possible number of meetings from a day's list, where each meeting has a known start and end time and two meetings cannot share the room if they overlap. Which greedy order picks a maximum set of non-overlapping meetings?
Difficulty: Easy
MCQ-32A room tool counts peak simultaneous meetings from a day's list, storing each meeting as a half-open interval [start, end). Two rooms merge into one pool that must never exceed 2 bookings, and a 10-minute buffer follows each meeting's end. Meeting A is 09:00 to 10:00, B is 10:00 to 11:00, and C is 09:30 to 10:30. Which handling of the buffer and the sweep returns the correct peak and shows whether the pool limit is breached?
Difficulty: Medium
MCQ-33A median service must find the median of two sorted int arrays, one with 1,000,000 values and one with 10 values, by binary searching a partition point. Each probe splits one array and checks the boundary values on both sides. Which search range keeps the number of probes minimal?
Difficulty: Medium
MCQ-34A gateway enforces a token bucket with burst capacity 100 and refill rate 10 tokens per second, and the bucket starts full. Refill is continuous and capped at 100. A client sends requests back-to-back, each admitted request spends one token, and the gateway's one-second window opens at the instant the first request is admitted. How many requests can the gateway admit inside that window?
Difficulty: Medium
MCQ-35Two elevator cars serve a 12-floor building. Car A is moving up with car calls still pending above floor 4, and car B is parked with an empty stop queue. A down hall call at floor 4 arrives, and the scheduler must not reverse any car in motion. Which state must it read before assigning the call?
Difficulty: Medium
MCQ-36A Java logging library keeps its sinks in a plain ArrayList. Every request thread calls log(), which runs a for-each loop over the sinks and writes each record to a file sink and a network sink. An admin endpoint calls addSink(networkSink) at runtime while traffic is flowing, and no lock guards the list. Which failure does this design show, and what change removes it?
Difficulty: Medium
MCQ-37A vending machine controller keeps `state` as a string with values idle, selecting and vending, and each handler guards its own transition. The select button is wired to fire even while the machine is idle, and a customer presses it with no credit inserted. The firmware is frozen for this release, so the change must sit in the state model itself. Which design makes an illegal transition impossible to write?
Difficulty: Medium
MCQ-38A Java bounded queue of capacity 4 guards its buffer with one ReentrantLock and a notEmpty Condition. Two consumers wait in take() using `if (count == 0) notEmpty.await();`. A producer puts one item and calls notEmpty.signalAll(). Before either woken consumer reacquires the lock, a new consumer calls take() and removes that item. What does the first woken consumer do next?
Difficulty: Hard
MCQ-39A URL shortener builds each code from a fixed number of characters drawn from base62, which has 62 symbols (a-z, A-Z, 0-9). Which quantity gives the number of distinct codes of length n?
Difficulty: Easy
MCQ-40A gateway admits 1000 requests per minute across 20 nodes. Each node enforces its own local token bucket by default. Two requirements apply. A partitioned node must keep serving its clients for up to 60 seconds instead of dropping them. If a node dies, aggregate admitted throughput must recover to at least 950 requests per minute within two minutes. Which design meets both requirements while the admitted total never exceeds 1000 requests per minute?
Difficulty: Hard
MCQ-41A cache tier spreads keys over 100 servers with consistent hashing, one point per server on the ring, and keys hash uniformly across the ring. Operators add a 101st server at a random ring position. In expectation, what share of the keys stored before the change are remapped?
Difficulty: Medium
MCQ-42An orders table is range-partitioned on order_id, a bigint from a sequence, into 12 partitions of 10 million IDs each. Inserts run at 3,000 per second and all land in the newest partition, which saturates its index while the other 11 partitions sit idle. Reports read the last 24 hours of IDs as one contiguous range, and that query must not fan out to every partition. Which change spreads the inserts while keeping that range read to a few partitions?
Difficulty: Hard
MCQ-43A read-through cache has no request coalescing. When a hot key's entry expires, 40 requests for that key arrive during the refill. How many requests reach the origin for that key?
Difficulty: Easy
MCQ-44A load balancer spreads requests over 4 backends with round robin at 1,000 requests per second total, and each backend allows 50 pooled connections from the balancer. Backend 3 slows from 40 ms to 400 ms per request while the other three stay at 40 ms, and its CPU is idle. As its latency rises, which symptom appears first?
Difficulty: Medium
MCQ-45A checkout API runs 12 pods behind a load balancer. On each rolling deploy a pod receives SIGTERM and exits at once, and about 4% of `POST /charge` calls fail with connection reset. Requests take up to 6 seconds, and the load balancer health-checks each pod every 5 seconds. Which signal should the pod send so the load balancer drains it without cutting in-flight requests?
Difficulty: Medium
MCQ-46A social app shards its messages table by user_id across 16 MySQL shards. Its thread view must show each message with the display name and avatar of its sender, and every thread mixes senders whose rows live on different shards. Which consequence of this sharding is most costly for that view?
Difficulty: Medium
MCQ-47An inventory service runs on MySQL 8.0 InnoDB at the default REPEATABLE READ, with connections in autocommit mode. Checkout reads `stock` with a plain SELECT, subtracts one in app code, then writes it back. With stock at 5, two checkouts for one unit each read 5 and the row ends at 4. The schema is frozen this sprint and the team will not add retry loops. Which change prevents the lost update?
Difficulty: Medium
MCQ-48A store has `N = 5` replicas and uses `W = 3` and `R = 2`. A write is acknowledged once 3 replicas hold it, and a later read asks 2 replicas chosen at random. Read repair is off, and one test read returned an older value from two replicas that missed the write. With `W` held at 3, what is the smallest read quorum `R` that guarantees every read sees the latest acknowledged write?
Difficulty: Easy
MCQ-49An inventory service runs 5 replicas, 3 in region A and 2 in region B. A network partition cuts the regions apart for 20 minutes. Both sides keep accepting stock decrements because checkout must never fail, and each side starts with 10 units and sells 7 before the partition heals. Which outcome does this choice produce once the replicas merge?
Difficulty: Medium
MCQ-50A consumer reads invoice requests from a queue with at-least-once delivery and writes each invoice to Postgres. It crashed after writing three invoices but before committing its offset, so the same three messages arrive again on restart. Each message carries a unique message_id, and the invoices table has a primary key on invoice_id, a value the consumer generates fresh on each attempt. Which change makes the second processing harmless?
Difficulty: Easy
MCQ-51A topic `orders` has 3 partitions keyed by order_id. Group `billing` runs 2 consumers and group `analytics` runs 1. The producer sets `enable.idempotence=false`, `max.in.flight.requests.per.connection=5` and retries. A batch to partition 1 fails once, and a later batch to partition 1 succeeds before the retry lands. Which outcome holds?
Difficulty: Medium
MCQ-52A producer publishes 900 messages per second into an in-process unbounded queue, and one consumer drains 300 per second. Each message is 1 KB and the queue may use 1.2 GB of heap before the process is OOM-killed. Ignoring GC pressure, after how many seconds does the heap run out?
Difficulty: Medium
MCQ-53A support console pages a 10^7-row `orders` table ordered newest first, 50 rows per page. About 200 inserts per second arrive, each with a larger bigint `id` from a sequence and a `created_at` set by the app. An operator loads page 1, then requests page 2 eight seconds later and wants no row repeated or skipped. Which pagination keeps results stable?
Difficulty: Medium
MCQ-54A mobile client calls a payments API that answers 429 with no Retry-After header. Its base delay is 200 ms, each retry doubles the previous delay, and the cap is 30 s. The first retry waited 200 ms, and five retries have already failed while eight clients share this limit. Which delay should the client sleep before the sixth retry?
Difficulty: Medium
MCQ-55Two services, each 99.9 percent available, sit in series so a request succeeds only when both respond. What is the approximate availability of the pair?
Difficulty: Easy
MCQ-56A search tier serves 50 million requests a day, with 70 percent of them in a 09:00 to 17:00 UTC window. Each request fans out to 4 shards, and the team sizes for the 3x peak of the busy window's per-shard rate. What peak shard-request rate should capacity be provisioned for?
Difficulty: Medium
MCQ-57An autocomplete endpoint must return the top 10 product names for a typed prefix with p99 under 50 ms. The index holds 2 million names ranked by a score that changes only in a nightly batch. For prefix `ca` there are 310,000 matches, and the current code walks to the prefix node, then scores every match with a size-10 heap, giving p99 of 180 ms. Which change meets the latency target?
Difficulty: Medium
MCQ-58Two app servers mint Snowflake-style IDs, with the millisecond timestamp in the high bits. Server B's clock runs 5 ms behind server A's, so IDs from B can carry smaller timestamps than IDs A issued earlier. Which ordering guarantee can no longer be relied on?
Difficulty: Easy
MCQ-59A lock service grants leadership with a lease and a fencing token that rises on every grant. Leader A holds token 33, stalls in a 15-second GC pause, and its lease expires. Leader B is granted token 34 and writes to the shared store. When A resumes and sends its write carrying token 33, which mechanism stops that write from landing?
Difficulty: Easy
MCQ-60A key-value store runs 6 replicas, 3 in region A and 3 in region B, with a round trip between regions that is far longer than the round trip inside a region. A write is acknowledged once W=4 replicas hold it, and the coordinator in region A sends each write to all six replicas at once. What latency does the coordinator add to each write before it can acknowledge?
Difficulty: Medium
MCQ-61A circuit breaker opened after 50 failures in 10 seconds, and its open timeout has now elapsed, so it enters the half-open state, which allows 3 trial calls through. While those 3 trials are still in flight, a fourth request arrives. What does the breaker do with it?
Difficulty: Easy
MCQ-62After a regional outage, 1000 clients all fail at t=0 and retry with exponential backoff: the attempt-three cap is 4 s (base 1 s, doubling). With full jitter, each client's retry delay is drawn uniformly from [0, 4 s] for that attempt. In expectation, roughly how many of the 1000 retries land in the first 100 ms of that attempt's window?
Difficulty: Easy
MCQ-63A checkout request carries a 2 second deadline set at the gateway and then passes through four services in a chain: gateway, auth, orders and inventory. The gateway spends 120 ms before it calls auth, and auth spends 80 ms before it calls orders, which must now call inventory. Each hop must bound its wait so the whole request still finishes inside the original deadline. What timeout should orders give the inventory call?
Difficulty: Easy
MCQ-64A flash sale holds 500 tickets in one Redis key on a single primary. 40 percent of the 50,000 checkout writes per second decrement it, about 20,000 per second, and stock must never fall below zero. Which mitigation keeps those decrements consistent at that rate?
Difficulty: Medium
MCQ-65A routing service must return the fewest moves between two cells on a 1000 by 1000 grid with obstacles, where every move to a neighbouring cell costs exactly 1. Which search finds that shortest move count?
Difficulty: Easy
MCQ-66A leaderboard holds 10^7 players with integer scores from 0 to 999,999, and ties are allowed. Scores change about 50,000 times per second, and a rank query must return 1 plus the number of players with a strictly higher score. The service has a 16 MB heap budget. Which structure answers rank queries in O(log n) time, keeps score updates logarithmic, and fits the budget?
Difficulty: Medium
MCQ-67A candidate's story: payments errors climbed to 38% after a config push, the team rolled back, and the error rate fell soon after. The interviewer asks how the candidate knows the rollback ended the outage and not a coincidental traffic dip. Which detail in the story answers that?
Difficulty: Easy
MCQ-68In a design review you argued that the nightly billing reconciliation job should stay on cron until the queue migration has survived a retry test, but the lead chose to cut over this sprint. You own the migration ticket. Three weeks in, staging shows that retried queue deliveries write duplicate invoices. Which step do you take next?
Difficulty: Medium
MCQ-69Your team cut the cart-to-payment page's p75 load from 2.4 s to 1.6 s by deferring a fraud-score call, and the dashboard confirms the speedup. Two weeks later, refund requests for orders placed in that window rose from 0.3% to 1.1%, and the fraud team says the deferred call is what catches stolen cards. Which metric should you bring to the review to show whether the trade-off cost customers?
Difficulty: Medium
MCQ-70Release 4.2 raised checkout p99 latency from 80 ms to 240 ms. It bundled a JSON serializer swap, a retry timeout change from 300 ms to 900 ms and a new cache key, and the staging load replay showed the same regression. The team can run one more staging build before the freeze. Which build best isolates the cause?
Difficulty: Hard
MCQ-71A senior SDE shipped a retry change that double-charged a payments partner and admitted the mistake in the incident channel that afternoon. Two months later the manager asks which evidence shows the partner's trust was earned back, rather than only that the incident was closed. Which detail should the candidate cite?
Difficulty: Hard
MCQ-72A candidate rewrote a checkout service and measured p99 latency with the same load test before and after the change. Two teammates also changed the cache that sprint, but the cache was not in the benchmarked build. In the interview, which claim about the result is most defensible?
Difficulty: Medium
MCQ-73A payments team must cut its nightly reconciliation bill by 40 percent this quarter. The job reads 2 TB from the ledger and writes audit output that regulators must keep for 90 days. The contract also requires a copy in a second region with a 15-minute recovery point. Which cost change should the team propose?
Difficulty: Hard
MCQ-74A booking service merges sorted meeting intervals with a single output list, and each merge step compares the new start with the last output end. A test suite with only disjoint meetings passed. Sorted input [1,10], [2,3], [4,5] is merged, and the team's draft sets the last output end to the new interval's end whenever they overlap. Which result does the draft return for this input?
Difficulty: Medium
MCQ-75A concurrent LRU cache's put evicts the tail node on one thread while a get on another thread moves that same node to the head. The corrupted list appears in about 1 run in 5,000 under stress testing and cannot be reproduced on demand. The team must find this interleaving and replay the failing order on every run. Which technique should they use?
Difficulty: Hard
MCQ-76A diff replaces a hash lookup with a nested loop: for each of 10^5 orders, it scans all 10^5 inventory rows to find a match. Which regression should the reviewer flag as most serious?
Difficulty: Easy
MCQ-77A payments team must give a planning lead a date for a checkout feature. Its own work is 9 weeks and needs an identity service from another team, which will ship by week 3 or slip past week 10. The identity team publishes its date at a week-3 checkpoint, and the feature's launch is fixed to a compliance window that closes at week 12. Which estimate should the team send?
Difficulty: Hard
MCQ-78A team of eight ships one Java monolith through a single deploy pipeline that takes 50 minutes. Billing needs its own PCI-scoped release every two weeks, but its changes wait behind unrelated checkout work in the shared queue. Search and catalog ship together without trouble and rarely change. Which change most justifies splitting a service out of the monolith?
Difficulty: Easy
MCQ-79A Java binary search runs over a sorted int array of 3,000,000,000 slots, which is not possible in a 32-bit index, so the team uses a long-indexed array of length 2,000,000,000 where low and high sit near 1,999,999,999. The code computes mid with 32-bit int arithmetic in a loop that runs about 31 times per lookup. Which midpoint expression gives the lower middle index without signed 32-bit overflow?
Difficulty: Medium
MCQ-80A dedup job folds the int array [4, 0, 4, 9, 9, 0, 6] into one running integer with XOR, starting from 0 and visiting each value once. Every value appears twice except one. What does the accumulator hold after the last element?
Difficulty: Easy
MCQ-81A session cache uses a Bloom filter in front of its database to skip lookups for keys never written: 1,000,000 bits, 7 hash functions, sized for 100,000 live keys. On logout the service clears the 7 bits of each removed key in place, and 20,000 keys have been removed this way. Lookups for live keys now sometimes miss the filter. Which change stops that without a rebuild?
Difficulty: Medium
MCQ-82A payments service moves money with `transfer(src, dst, cents)`, which takes a mutex on each of the two accounts. Account IDs are fixed integers set at creation, while balances change on every transfer. Two threads run `transfer(17, 42, 500)` and `transfer(42, 17, 300)` at the same moment and deadlock. Which lock-ordering rule stops this while keeping one mutex per account?
Difficulty: Easy
MCQ-83A table has a composite B-tree index on (a, b), and the query planner must choose between an index scan and a sequential scan for each query. Which WHERE clause cannot use that index to seek to matching rows?
Difficulty: Easy
MCQ-84A root-run daemon takes its instance lock by calling `lstat(path)`, which returns ENOENT, and then calls `open(path, O_CREAT|O_WRONLY, 0600)` in /run. Users in group `ops` can write to that directory. A second instance must be refused while the first is alive. Between the two calls, a local user can plant a symlink at `path` that points to /etc/shadow. Which single change removes the window and keeps the refusal?
Difficulty: Medium
MCQ-85A transfer touches accounts on three participant databases under two-phase commit. All three voted yes in the prepare phase and hold row locks. The coordinator crashed before any participant received a decision, and its decision log cannot be read until it restarts. Participant P2 asks P1 and P3 for the outcome and both report prepared, neither committed nor aborted. What should P2 do next?
Difficulty: Easy
MCQ-86A feed receives 10^6 closed intervals [start, end] one at a time and keeps a disjoint, merged set current after each arrival. Each arrival must find every stored range it touches and collapse them into one, at O(log n) per arrival and without a full rescan. Ranges touching a new interval are found by a single search on the stored starts. Which structure supports the ordering this requires?
Difficulty: Medium
MCQ-87A service reads 10^9 integer scores from one stream in a single pass and must report the 10 largest, with memory capped at about 100 bytes of working state. A bounded structure of size 10 is the only option that fits. Which structure should it keep?
Difficulty: Easy
MCQ-88A parking lot's Spot class has can_park(vehicle), which checks the vehicle's size against the spot's size. A find_spot loop asks each spot in the lot's list in turn, and the lot is built from a list passed to its constructor. Charging spots must be offered to electric cars, but Spot, can_park and find_spot are covered by tests and must not change. Which change adds charging spots without editing that logic?
Difficulty: Medium
MCQ-89A checkout service computes fees with one function that branches on a provider code: stripe takes 2.9% plus 30 cents, adyen takes 2.6% plus 10 cents capped at 4 dollars, and bank transfer charges 1.5% but waives the whole fee for domestic buyers when the order total is under 5 dollars. The total for the waiver includes a 0.5% currency surcharge, so a 4.98 dollar order is checked as 5.0049 dollars. Each new provider forces an edit and retest of this function. Which change adds bank transfer with no edit to the existing fee code and still applies the surcharged waiver check?
Difficulty: Hard
MCQ-90A billing consumer reads one Kafka partition in order. One record has a malformed currency field that no retry can repair, and finance replays rejected records, so the record must not be lost. Other partitions in the same consumer group must keep flowing. What should the consumer do with that record?
Difficulty: Easy
MCQ-91A payment service runs six pods over one Postgres database and forwards each charge synchronously to a card network that offers no request deduplication. A client POSTs a 4,200-cent charge, times out after 3 s while the pod is still waiting on the network, and the charge later succeeds. The client resends the same POST 5 s later, and the first attempt may still be in flight. Which mechanism stops the resend from creating a second charge?
Difficulty: Hard
MCQ-92Laptop A, offline, edits paragraph 2 of notes.md. Laptop B, also offline and starting from the same revision 7 that the client last synced, edits the final section. Both reconnect at the same moment. The sync client must publish one file that keeps both changes, with no prompt to the user. Which strategy does this?
Difficulty: Medium
MCQ-93At 14:05 the payments error rate jumped from 0.4% to 38%, minutes after a release that changed the checkout client and added a checkout feature flag. CPU and connection pool usage are flat at about 40%, so the errors are not capacity-related. Rolling back the release takes about 25 minutes, while the flag can be switched off at the gateway in under 10 seconds and switched back the same way. What should the engineer do first?
Difficulty: Easy
MCQ-94A Java order service's old generation grew about 40 MB an hour until a fix deregistered a request listener on cancel. The fix shipped to 2 of 12 pods as a canary, and the other 10 still run the old build. Both groups see the same daily traffic cycle. Which evidence shows the leak is gone rather than hidden by a quieter traffic period?
Difficulty: Hard
MCQ-95A checkout service calls a payment provider's capture endpoint through a PaymentGateway client passed into its constructor. The provider's sandbox cannot be told to capture a charge and then drop the response, and the team must prove that a 4,200-cent charge is never captured twice when the capture succeeds, the response is lost to a timeout, and the service retries with the same idempotency key. Which test setup proves this?
Difficulty: Hard
MCQ-96A creator with 10 million followers publishes one post, and the feed service must not write one timeline row per follower when it is published. Which write strategy avoids that per-follower write at post time?
Difficulty: Easy
MCQ-97A batch job applies 10^6 union operations and then 10^6 connected-component queries over 10^6 nodes. Pairs arrive in an order the job does not control, each node's parent is kept in an int32 array, and each root already holds its component size. Which pair of optimizations gives near-constant amortized cost per operation?
Difficulty: Medium
MCQ-98A payments worker retries a failed charge to a provider that accepts an idempotency key and remembers it for 10 minutes. A retry sent after that window carries no deduplication, so the provider treats it as a new charge. Which retry design keeps the charge single for a retry that might land after the window closes?
Difficulty: Easy
MCQ-99A checkout service picks the nearest of 40 warehouses by straight-line distance for each cart, on every request, with a 5 ms budget per call. The service runs on a 2-vCPU container with a 64 MB heap, and each request arrives in a batch of 500 carts that share one request thread. The 40 coordinate pairs are stored as doubles, change once a day, and are read-only at request time. A design review proposes a k-d tree rebuilt daily to cut comparisons below 40 per cart. Which approach should the service use for each lookup?
Difficulty: Hard
MCQ-100A metering service receives 10^6 meter readings in arrival order, and repeated values are allowed. For each reading it must return the position of the nearest earlier reading from the same day whose value is at least as large, or none if there is none. The budget is 1 second on one core, and the readings cannot be sorted. Which approach gives these answers within budget, and what does a reading equal to an earlier one return?
Difficulty: Hard