awesome-everything RU
↑ Back to the climb

Algorithms from zero

Toolbox: technique-selection review

Crux Cross-track multiple choice: read each problem, then pick the technique and the reason, weighing complexity, data structure, and the failure mode of the wrong tool.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at middle altitude — in the sky
◷ 14 min

The whole track collapses into one skill: read a problem and name the right tool before you write a line. Each question hands you a problem statement and asks not ‘what is the answer’ but ‘which technique, and why that one over the tempting wrong one’.

Goal

Confirm you can map a problem’s shape — its constraints, its structure, what it asks — onto the technique that fits, and explain why the obvious alternative fails or wastes time.

Quiz

You are given an unsorted array of 10^6 integers and must answer 10^5 queries of the form 'does value X exist?'. Which approach, and why?

Quiz

A problem asks for the number of distinct ways to make change for amount N using given coin denominations. N is up to 10^4. Which technique, and what is the tell?

Quiz

You must find the k smallest elements of a stream of n numbers (n unknown in advance, k fixed and small). Which data structure carries the technique?

Quiz

Given a sorted array, find two indices whose values sum to a target. The array can be huge and you must use O(1) extra space. Which technique?

Quiz

You must detect whether a directed dependency graph has a cycle, and if not, produce a valid build order. Which technique?

Quiz

A problem gives n <= 20 items and asks for the optimal subset under a constraint that resists any greedy or DP-by-value formulation. The constraints scream a particular family. Which, and what is the n <= 20 tell?

Recap

Technique selection is reading, not recall. Constraint sizes are the loudest signal: n ≤ 20 licenses 2^n enumeration; n ≤ 10^5 demands O(n log n); 10^9 forces O(log n) or math. The problem’s verb picks the family — does it exist maps to hashing; k smallest or next priority maps to a heap; ways to count or optimise over overlapping subproblems maps to DP; best local choice you can prove maps to greedy; order by dependency maps to toposort; pair in sorted data with O(1) space maps to two pointers. Every wrong answer above is a real tool misapplied — the skill is matching shape to tool, then knowing why the tempting alternative wastes time or breaks.

Continue the climb ↑Toolbox: free-recall review
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.