- LeetCode 31 – Next Permutation
A problem you either see or you do not — no data structure, no recursion, just three passes in the right order. It starts from one observation: a descending suffix is already maximal, so the change has to reach further left than it goes. Finding the pivot, why scanning from the right finds the smallest larger value for free, and why reversing beats sorting the suffix.
- LeetCode 28 – Implement strStr()
Reimplement indexOf. The honest answer to 'do I need to write KMP?' is almost always no — the interviewer wants a clean nested loop with correct bounds, and the bounds are the entire problem. Why i <= n - m is not a typo, how it handles a too-long needle for free, why not to allocate a substring per position, and how to raise KMP without walking into it.
- Concurrency – Double Booking and Distributed Locks
Two guests, one room, the same millisecond. Why the check-then-write everyone writes first is always wrong, optimistic against pessimistic locking, the database constraints that make a race impossible rather than unlikely, idempotency keys for requests that must not run twice, and distributed locks — what they cost, how they fail, and why they belong last on the list rather than first.
- LeetCode 23 – Merge k Sorted Lists
Merging two lists is solved; the question is in what order you merge k of them, and the obvious order costs a factor of k. Where that extra factor comes from, why pairwise merging gets it to O(N log k), and an honest comparison of divide-and-conquer against a min-heap — same time, different space, and only one of them survives the streaming follow-up.
- Message Queues and Asynchronous Work
Why the line after a commit is the most dangerous line in the file, and what to do about it. Queues against logs, at-least-once delivery and the idempotency it forces, the transactional outbox, retries with exponential backoff, dead-letter queues, and how a worker claims work without two workers doing it twice. Every piece taken from a queue that runs, including the duplicate it produced.