- 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.
- LeetCode 156 – Binary Tree Upside Down
Pure pointer surgery with no search and no complexity to argue about. The whole problem is doing four assignments in an order that does not destroy what the next one needs — null out root.left before reading it and the subtree is gone. Both pointers must be nulled, not just one.
- LeetCode 152 – Maximum Product Subarray
Kadane with multiplication, and the change is bigger than it looks: a large negative is not a bad prefix, it is a latent good one waiting for another negative. Carry the minimum as well as the maximum, and watch the assignment order — curMin needs the OLD curMax.
- MongoDB – Schema Validation
$jsonSchema, validation levels and actions — and why a flexible store still wants rules at the boundary.