- LeetCode 159 – Longest Substring with At Most Two Distinct Characters
The sliding window at its most reusable, and unlike Minimum Window Substring it generalises to k by changing one literal. The single bug it has: a count that reaches zero must be DELETED, not left sitting there, or the map size counts characters that have already left the window.
- MySQL Interview – Advanced Queries
The whiteboard questions that separate people who have written SQL from people who have read about it. Second-highest value, top N per group, finding and deleting duplicates, a running total, gaps in a sequence, a pivot with conditional aggregation, rows in one table with no match in another, and month-over-month growth — each one solved, then explained, then checked against a real database.
- LeetCode 158 – Read N Characters Given Read4 II – Call Multiple Times
The same API with one sentence changed, and that sentence changes the design rather than the code. Problem 157 discards the surplus from its last chunk; called twice, that surplus is lost data. Three fields of state, and you have written a buffered reader.
- LeetCode 157 – Read N Characters Given Read4
An API-adaptation problem: a primitive that reads in 4-character chunks, a caller that wants exactly n. A short read means end of file, and both limits need guarding — writing past n is a buffer overrun into the caller's memory, not a wrong answer.
- MySQL Interview – Fundamentals
The questions almost every SQL interview asks, answered the way you would say them out loud. The difference between the joins, WHERE versus HAVING, DELETE versus TRUNCATE versus DROP, what an index actually is and its cost, primary versus unique key, NULL behaviour, the ACID properties with an example each, normalization up to third normal form, and UNION versus UNION ALL.