- LeetCode 121 – Best Time to Buy and Sell Stock
Worth more than its Easy tag, because the reframing it teaches is the one behind Kadane's algorithm and most 1-D DP. The brute force asks which pair of days is best; the linear solution asks what the best buy was if I sell today — and that has a one-variable answer. Why a falling market returns 0, and why this is Maximum Subarray in disguise.
- LeetCode 49 – Group Anagrams
A hashing problem wearing a string problem's clothes. Find something identical for anagrams and different for everything else, then group by it. Sorting each word works; counting letters is better. And the separator everyone forgets — without it a word with 1 a and 11 b's collides with one that has 11 a's and 1 b.
- LeetCode 47 – Permutations II
Permutations with duplicates, and the extra line is a different extra line from the one Combination Sum II uses — which catches people who think they already learned this trick. With no start index, used[] is the only signal of depth, so the rule becomes !used[i-1]. All three de-duplication rules compared side by side.
- 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.
- 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.