- LeetCode 20 – Valid Parentheses
The canonical 'you should have reached for a stack' problem. Nesting means the thing you must close next is the thing you opened most recently. The trick that shortens the code: push the closer you expect, not the opener, so the check becomes one equality test. Three failure modes, three checks — and why ArrayDeque beats the legacy Stack.
- LeetCode 19 – Remove Nth Node From End of List
You cannot walk a singly linked list backwards, so the nth node from the end has to be found from the front. Two pointers held a fixed distance apart do it in one pass — but the gap is n + 1, not n, because unlinking a node needs the node before it. Why the dummy head is not optional here, and an honest note on what 'one pass' actually buys.
- Scaling the Database
The order to do things in, because most systems reach for sharding several steps too early. Indexes and query plans, connection pooling, read replicas and the replica lag that breaks read-your-writes, vertical against horizontal, partitioning versus sharding, choosing a shard key you will not regret, hot shards, and what resharding actually costs once you are live.
- LeetCode 15 – 3Sum
The problem that teaches sort-then-two-pointers. The algorithm is the easy half; the half that decides whether you pass is de-duplication, and there are two separate places a duplicate gets in. Why sorting buys three things at once, why the anchor skip must compare backwards, and why no solution can beat O(n²) when the output itself can hold that many triplets.
- LeetCode 14 – Longest Common Prefix
A five-minute problem whose only real content is the edge cases. Scanning vertically — one character position down the whole array before moving right — is shorter than the horizontal version, exits at the first mismatched column, and makes the bounds check handle both short strings and empty ones in a single line. Plus the sorting trick, and why it is the worse answer.