- 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.
- Caching – Patterns, Invalidation and What Breaks
A cache-aside read on a real endpoint, measured cold and warm, then everything that makes caching hard rather than easy. Write-through against write-behind, TTL and eviction policies, the two invalidation strategies and why you want both, cache stampede and how to stop it, and the rule that decides whether a cache is an optimisation or a new single point of failure.
- LeetCode 13 – Roman to Integer
The inverse of Integer to Roman, and the trick that solved that one does not transfer. Going this way, all six subtractive pairs are handled by a single comparison: if a symbol is smaller than the one after it, subtract it. No table of pairs, no lookahead bookkeeping, and you never need to recognise CM as a unit. Java and Python, plus why not to rebuild a HashMap on every call.
- LeetCode 12 – Integer to Roman
It looks like it needs a pile of special cases — four is IV, nine is IX, forty is XL. It does not. Put the six subtractive pairs into the symbol table as if they were symbols in their own right, and the problem collapses into a plain greedy loop with no branches at all. Why greedy is provably safe once the table is descending, and why String += is the wrong way to build the answer.