Interview Flowchart — A 20-Minute Diagnostic
Turn the Interview Flowchart into a repeatable script: clarify, pattern match, and choose the right tool without freezing mid-round.
Problem Statement
Whiteboard rounds collapse when you jump into code before validating assumptions. The Interview Flowchart gives you a consistent checklist for the opening 15–20 minutes so you never skip clarification, brute force, or the right pattern search.
Why This Problem Matters
- Interviewers judge how you navigate ambiguity as much as your final code. A flowchart-backed script shows poise under pressure.
- Pattern matching quickly surfaces whether you should reach for hash maps, sorting, two pointers, heaps, or recursion—mirroring the guidance from the flowchart.
- Having a rehearsed diagnostic prevents tunnel vision; you can explicitly explain trade-offs (time vs. space, greedy vs. DP) before implementing anything.
Thought Process
Clarify before you optimise
Spend the first five minutes repeating the problem, writing down constraints, and pitching the brute-force baseline. Ask where the repeated work or bottleneck sits—directly echoing the flowchart opening lane.
Run the pattern gauntlet
March through the flowchart prompts: hash map? sort + binary search? two pointers? heap for top-K? recursion/backtracking? Each "no" narrows your search space while narrating your reasoning.
Pick an upgrade path
Once a pattern sticks, articulate the trade-off (e.g., extra memory for linear time, or greedy vs. DP). Tie the decision back to the earlier pain point you spotted during clarification.
Step-by-Step Reasoning
- Minute 0–2: Restate the prompt, confirm inputs/outputs, and log constraints (ranges, mutability, streaming vs. batch).
- Minute 2–5: Sketch the brute-force idea and highlight the exact loop/nested structure that makes it slow.
- Minute 5–10: Walk the flowchart branches—hash maps, sorting/binary search, two pointers, greedy, recursion, heaps, tries. Stop when one eliminates the earlier bottleneck.
- Minute 10–15: Outline the improved algorithm, complexity, and edge cases. Validate with a mini dry run before touching code.
Visual Flowchart
Dry Run
Prompt: "Find longest palindromic substring."
After clarification, we learn the input string can be up to 2,000 characters long. The brute force approach of checking all substrings would be O(n³) since we need to generate all substrings O(n²) and verify each one O(n). Reviewing the flowchart, the "Two pointers / middle out" pattern suggests expanding around each center character, which reduces complexity to O(n²) while solving the problem.
Prompt: "Return K most frequent elements."
The baseline solution would be to count frequencies using a hash map, then sort by count, giving us O(n log n) time complexity. Following the flowchart, we identify this as a "Top K" problem. The flowchart guides us to use a heap: build a frequency map in O(n), then maintain a min-heap of size K, resulting in O(n log K) which is more efficient when K is much smaller than n.
Common Pitfalls
- Jumping to code after the first idea instead of finishing the clarification + brute-force phase.
- Name-dropping patterns ("maybe DP?") without linking them to the specific bottleneck you highlighted earlier.
- Ignoring interviewer hints that point you toward a different branch of the flowchart.
Follow-Up Questions
- Customise the flowchart for company formats (e.g., system design vs. algorithm).
- Record yourself running through the checklist to measure how long each phase actually takes.
- Create mini flashcards for each branch so you can swap in fresh examples during practice.