The skill that separates people who freeze from people who flow is not raw cleverness — it is recognition. Experienced candidates read a prompt and a technique lights up almost immediately, because they have learned to hear the signal buried in the wording. That recognition is learnable. This guide is the decoding table.
Why the prompt is a clue, not just a question
Interview problems are drawn from a small catalogue of patterns, and the way a problem is phrased leaks which one it is. Words like “sorted,” “contiguous,” “top k,” “shortest,” and “have we seen” are not decoration — they are the interviewer’s fingerprints on the underlying technique. Once you can name the signal, the problem stops being an open search of everything you know and becomes a lookup into a shortlist. The goal is to make the mapping from signal to tool so practised that it happens before you have finished reading.
The core mappings
Here is the field guide. Each line is a phrase or shape you will see in a prompt and the technique it usually points at:
- “The array is sorted” → binary search for a target, or two pointers from both ends. Sorted input is a gift; if the problem hands it to you, it wants you to use the order.
- “Find two numbers that…” / “have I seen this before” / “count occurrences” → a hash map or set. You are trading memory for
O(1)lookups. - “Longest / smallest contiguous subarray or substring” → a sliding window. The word contiguous is the tell; you grow and shrink a window instead of re-scanning.
- “Top k” / “k largest” / “k closest” → a heap of size k. You do not need to sort everything to find a few extremes.
- “Shortest path” / “fewest steps” / “level by level” → breadth-first search. “Explore every possibility” or “all paths” → depth-first search.
- “How many ways” / “minimum cost to…” with choices that repeat → dynamic programming. The signal is overlapping subproblems — the same smaller question answered again and again.
- “Next greater / smaller element” / “matching brackets” → a stack. Anything about nesting or the most recent unmatched thing is stack-shaped.
- “In place” / “
O(1)extra space” → pointer manipulation, swapping, or reversing — a constraint that rules out the copy-everything approaches.
Read the constraints, too
The signal is not only in the verbs; it is in the numbers. If n can be a million, an O(n²) solution is off the table and the phrasing is quietly demanding O(n log n) or better — which itself hints at sorting or a heap. If n is tiny, the brute force may be exactly what they want, and reaching for something clever wastes time. Treat the stated limits as part of the prompt, because they narrow the technique as sharply as any keyword.
Frontend-flavoured signals
The same read-the-signal skill applies well beyond algorithms, and frontend interviews lean on it constantly:
- “Fires too often” — scroll, resize, keystrokes, search-as-you-type → debounce or throttle. “Wait until it stops” is debounce; “at most once per interval” is throttle.
- “Thousands of list items” / “the page janks while scrolling” → list virtualization — render only what is on screen.
- “Handle clicks on many similar elements” → event delegation — one listener on the parent, not one per child.
- “The tap feels stuck” / “a long task blocks the main thread” → break the work up, defer it, or move it to a Web Worker — the responsiveness (INP) playbook.
- “Content jumps as it loads” → reserve space for images and late-arriving content to fix layout shift (CLS) at the source.
How to practise recognition
You build this the way you build any pattern library: reps with feedback. When you work a problem, before writing anything, force yourself to say out loud which signal you spotted and which technique it points at — then check whether you were right. Getting the mapping wrong is useful; it tells you which signal you are misreading. Over a few dozen problems the shortlist collapses to almost nothing, and you find yourself naming the pattern in the first sentence of the prompt. That first sentence — “this is a sliding-window problem because…” — is often the highest-value thing you say in the whole interview.
Every question in this collection is built around this pairing of signal and technique. Start with the DSA questions and their decision table, then widen out across all areas — the JavaScript, React, and performance questions reward the same habit of reading the prompt for what it is really asking. For the algorithm round specifically, pair this with how to approach any DSA problem.