Technical Interviews
Coding Interview Problem-Solving Framework: Decomposing DS&A Without Memorization

The most common mistake candidates make in coding interviews is trying to recognize the problem rather than solve it. They pattern-match to a memorized solution, attempt to reproduce it, and fail — either because the problem is a variant they don't recognize, or because pressure-induced retrieval failure breaks the memorized sequence mid-implementation.
The alternative is a decomposition framework that produces correct solutions to unfamiliar problems through systematic reasoning, not pattern recall.
The Seven-Step Problem-Solving Protocol
Step 1: Read Carefully and Restate (2 minutes)
Before writing a single line of code, restate the problem in your own words:
"So if I understand correctly, I'm given a sorted array of integers and need to find the index of a target value, returning -1 if it's not present. The input can be up to 10^7 elements — which suggests I need better than O(n) time. Does that capture it?"
This confirms you understood correctly, surfaces misunderstandings before you've invested time in the wrong direction, and demonstrates communication quality.
Step 2: Clarify Constraints and Edge Cases
Ask before designing any solution:
Input constraints: "Can the array contain duplicates? Can values be negative? What's the maximum length?"
Output constraints: "If there are multiple valid answers, return all of them or just one? Does order matter?"
Edge cases: "What should I return for an empty input or null?"
Wrong assumptions about constraints produce correct solutions to the wrong problem.
Step 3: Work Through a Small Example by Hand
Take a 5–7 element example and trace through it manually. This reveals the algorithmic pattern, creates a test case for later verification, and shows the interviewer your thinking.
Example: Find all pairs in [1, 2, 3, 4, 5] that sum to 6.
By hand: (1,5), (2,4). Pattern: for each element,
we need to check if (target - element) exists. → Hash map.
Step 4: Identify the Problem Category
Most problems belong to recognizable categories:
| Pattern | Tell-tale Signs | Common Approach |
|---|---|---|
| Two pointers | Sorted array, pairs, subarray constraint | Left/right pointers moving inward |
| Sliding window | Subarray/substring with sum or length constraint | Expand/contract window |
| Binary search | Sorted structure, minimize/maximize monotonically | Halve search space each iteration |
| BFS / DFS | Graph traversal, shortest path, connected components | Queue (BFS) or recursion (DFS) |
| Dynamic programming | Overlapping subproblems, optimization over choices | Memoization or bottom-up table |
| Greedy | Local optimal leads to global optimal | Sort by criterion, iterate |
| Hash map | Fast lookup, counting, deduplication | O(1) insert and lookup |
| Heap | K-th largest/smallest, streaming min/max | Min-heap or max-heap |
You don't need to identify the perfect category immediately — you need a starting hypothesis.
Step 5: Propose Brute Force First
Always articulate the brute force approach before optimizing:
"The naive approach checks every pair — O(n^2) time, O(1) space. I'll describe that first, then optimize."
This demonstrates you can get to a working solution, establishes a baseline to beat, and often reveals the optimal solution's structure (the bottleneck in brute force usually points directly at the right data structure). If time runs short, a working brute force beats an incomplete optimized solution.
Step 6: Optimize with Complexity Analysis
Identify what makes the brute force slow:
Repeated O(n) lookups → hash map (O(1) per lookup)
Redundant computation of the same subproblem → memoization or DP
Unnecessary full-array scans → binary search if data is sorted
Processing unsorted data repeatedly → sort once, then use linear techniques
State your target before coding: "I think I can get this to O(n) time and O(n) space using a hash map. Let me code that."
Step 7: Code, Test, and State Complexity
Code cleanly with descriptive variable names (left, right, current, target — not l, r, c, t). Return to your Step 3 example and trace through your implementation. Check your edge cases. Then state: "This is O(n) time and O(n) space. The hash map lookup is O(1) amortized, and we iterate through the array once."
Handling the Blank Moment
When you look at a problem and have no idea where to start:
Start with brute force. "I could check every possible combination" is a valid starting point — you can optimize from there.
Try concrete examples. A 3–4 element example solved by hand often reveals the pattern reading the description doesn't.
Eliminate approaches. "This can't be greedy because the locally optimal choice isn't globally optimal here. So I'm looking at DP or brute force with pruning."
Reasoning out loud while uncertain is far better than silence. "I'm not immediately sure which approach to use, but let me think through it" is exactly what interviewers want to hear.
Mistakes to Avoid
Jumping to code without a plan. Produces confused implementations and signals instinct-driven rather than design-driven coding.
Skipping brute force. Candidates who attempt the optimal solution directly often stall when the implementation is more complex than expected.
Silent coding. The interviewer can't evaluate reasoning they can't hear.
Not knowing your complexity. Every implementation deserves a complexity statement. If you can't state it, you haven't fully understood your own solution.
Practice Approach
This framework makes practice more efficient than memorizing solutions:
- After seeing a new problem, write down which category you identified and why — before looking at solutions.
- After implementing, ask: "What was the bottleneck in brute force? How did the optimal solution eliminate it?"
- Deliberately practice edge case identification — list every edge case before testing.
50 problems practiced this way develops stronger fundamentals than 300 problems solved by reading editorials.
The goal in a coding interview is not to recognize the problem — it's to demonstrate that you can solve unfamiliar problems through systematic thinking. The seven-step protocol gives you a reliable structure for doing exactly that, even when the problem is new and the pressure is high.
Deconstruct Complex Algorithm & Coding Challenges
Systematic problem decomposition separates instinctive coders from principled software engineers:
- Live Cognitive Scaffolding: Explore how real-time cues assist structured algorithm reasoning on Kairo Live AI Copilot.
- Target Role Preparation: Review software engineering interview benchmarks in the Kairo Technical Interview Questions Library.
- Plan Options: Review prep tiers and features on Kairo Pricing.
- Related Frameworks: