Top Programming Questions [Updated]
2 min read
🧠 Remember: “Study families, not problems.”
How to use this index
Don’t grind randomly. Pick a family, learn its 2–3 core moves, then let variants come to you. Start with the Warm Up if any family feels foreign.
Arrays & hashing
The highest-yield family. Core moves: complement lookup, running accumulators, sort-then-scan.
- Two Sum — complement hashing, one pass
- Contains Duplicate — seen-set membership
- 3Sum — sort, fix one, converge two
- Product of Array Except Self — left × right accumulators, no division
- Best Time to Buy and Sell Stock II — skim every positive climb
- Maximum Subarray — extend or restart running sum
- Merge Sorted Array — fill from the back
- Move Zeroes — stable partition, two pointers
- Majority Element — Boyer-Moore voting
- Missing Number — XOR or Gauss sum
- Single Number — XOR cancels pairs
- Sort Array By Parity — two-pointer partition
- Top K Frequent Elements — bucket by count
Strings & numbers
Parsing shapes: fold left → right, peek at the neighbor.
- Reverse String — converging pointers, in place
- Longest Substring Without Repeating Characters — sliding window + last-seen map
- Roman to Integer — smaller-before-larger subtracts
- Excel Sheet Column Number — base-26 with no zero
Trees
Traversal + recursion depth. Core moves: inorder structure, level tracking, divide and conquer.
- Maximum Depth of Binary Tree — 1 + max of children
- Binary Tree Inorder Traversal — left, node, right
- Binary Tree Preorder Traversal — node first, stack or recursion
- Binary Tree Postorder Traversal — children before node
- Convert Sorted Array to Binary Search Tree — mid-root recursion
- Kth Smallest Element in a BST — inorder is sorted
Backtracking
Choose, explore, unchoose. Core move: one shared path, add on entry, remove on exit.
- Permutations — swap-and-recurse over positions
- Subsets — take-or-skip each element
- Generate Parentheses — open-if-room, close-if-safe
Linked lists
Pointer surgery. Core moves: prev/curr rewiring, fast-slow spacing.
- Reverse Linked List — flip links walking forward
- Delete Node in a Linked List — copy next over self
🧠 Remember
Prep → “One family per session.” Depth in a family transfers; breadth across random problems doesn’t.
🔁 Stuck? Drop back to the Warm Up, then re-enter through Two Sum — the root of the hashing family.