Lesson 26 of 30
A quick way to translate the words in a problem into the tool you should reach for — built from everything else in this track.
12 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
This topic is about judgment and practical tradeoffs more than a single right answer — a mock interview is the better way to test yourself on it.
Be interviewed on this →Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
Think about a mechanic's toolbox. A good mechanic doesn't stare at an engine wondering which tool might work. Certain sounds and symptoms point straight at certain tools — a squeal points at the belt, a wobble points at the wheel bearing.
DSA interviews work the same way. Certain words in a problem point straight at certain tools. You've already learned the tools, one lesson at a time, throughout this track. This lesson is the index card that maps the words to the tools — so in the moment, you're not searching your whole memory, you're pattern-matching a few key phrases.
This isn't magic and it isn't a guarantee. It's a first guess that's right often enough to save you real time — and even when it's wrong, having a first guess beats having no idea where to start.
// This isn't runnable code — it's the cheat sheet itself, written as
// comments so you can keep it next to your editor while you practice.
// "The array is SORTED and I need a PAIR of numbers"
// -> think: two pointers (one at each end, walk them toward each other)
// "I need the best SUBARRAY or SUBSTRING" (a contiguous chunk)
// -> think: sliding window (grow/shrink a window as you scan once)
// "I need to check if I've SEEN something before, fast"
// "I need to COUNT occurrences, or look something up INSTANTLY"
// -> think: hash map (trade a little memory for near-instant lookup)
// "I need to explore ALL PATHS, CONNECTIONS, or NEIGHBORS"
// "the input is a GRID, a TREE, or a GRAPH"
// -> think: DFS (go deep down one path first) or BFS (spread out
// one layer at a time) — DFS for "does a path exist," BFS for
// "what's the SHORTEST path"
// "the problem is the SAME SMALLER problem, nested inside itself"
// -> think: recursion, possibly with the 'leap of faith' framing
// "I need to REVERSE, REORDER, or JUMP AROUND a chain of nodes"
// -> think: linked list pointer manipulation
Every row above points back to a lesson you already worked through earlier in this track — two pointers, sliding window, hash maps, DFS/BFS, recursion, linked lists. This lesson doesn't teach anything new; it's the index that helps you find the right page fast, under pressure.