- 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.
- LeetCode 22 – Generate Parentheses
The problem that teaches constrained backtracking. The lazy solution builds all 4^n bracket strings and filters; the intended one never builds an invalid string, because two small rules make it impossible. Why close < open is sufficient — not just true — the undo step everyone forgets, and why the output being Catalan-sized bounds any possible solution.
- Consistency, Availability and CAP
CAP without the folklore — what the theorem says, what it does not say, and why PACELC is the more useful version day to day. Strong against eventual consistency, read-your-writes and monotonic reads, quorums, and the dual-write problem that appears the moment a second datastore enters the design. Shown against a live Postgres-to-Elasticsearch sink, including exactly where it goes wrong.
- LeetCode 21 – Merge Two Sorted Lists
The merge step of merge sort, isolated. Worth writing carefully rather than quickly, because Merge k Sorted Lists calls it and so does sorting a linked list. The part people over-engineer: splice the remaining list on in a single assignment instead of looping it out. Why the space is O(1), and why <= rather than < is the detail that shows you were thinking.