- LeetCode 43 – Multiply Strings
Long multiplication as you learned it at school and then forgot. It hinges on one piece of index arithmetic — the product of digits i and j lands at i + j + 1, carrying into i + j — which is worth deriving rather than memorising. Why the result needs exactly m + n slots, and why an intermediate slot going above 9 is harmless.
- LeetCode 42 – Trapping Rain Water
One of the most-asked Hard problems, and it defeats people because they try to find the puddles. Do not. Ask how deep the water is above one column and the answer is one line: min(maxLeft, maxRight) − height. Why two pointers can decide with half the information, and the line ordering that silently returns a number slightly too small.
- MySQL – UNION and UNION ALL
Stacking result sets on top of each other instead of side by side. UNION versus UNION ALL and why the default deduplication is not free, the rules the branches have to satisfy, where ORDER BY and LIMIT go when there is more than one SELECT, MySQL 8's INTERSECT and EXCEPT, and when a UNION is the wrong tool and a conditional aggregate is the right one.
- LeetCode 41 – First Missing Positive
Hard because of its constraints, not its question — a hash set solves it instantly, and O(1) space forbids one. Everything follows from a single observation: with n elements the answer is always in [1, n + 1], so every other value is noise. Cyclic sort uses the array as its own hash table, and the nested loop really is O(n).
- MySQL – Self Join
Joining a table to itself, which is not a special kind of join — it is an ordinary join where both aliases point at the same table. Why the aliases stop being optional, comparing rows within a table, finding pairs without duplicating them with `a.id < b.id`, and the classic employee-and-manager shape done on a table you can actually see.