- LeetCode 46 – Permutations
The reference implementation of backtracking, and its value is the contrast with the combination problems. There a start index stops the same set appearing in different orders; here the different orders are the answer, so start disappears and used[] takes its job. Undo both pieces of state, or you get one permutation and then nothing.
- MySQL – GROUP BY and HAVING
Collapsing many rows into one per group. COUNT, SUM, AVG, MIN and MAX, grouping by several columns, HAVING versus WHERE and why they are not interchangeable, counting with COUNT(*) versus COUNT(column) when NULLs are involved, WITH ROLLUP for subtotals, and ONLY_FULL_GROUP_BY — the mode that is ON by default in MySQL 8 and rejects the sloppy GROUP BY that MySQL 5 quietly accepted.
- 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.