Coding interviews are not just about solving problems — they measure your communication, thinking process, and problem-solving skills, from gathering requirements all the way to testing and complexity analysis. If you only have one or two weeks to prepare, this is a short but effective preparation schema focused on training those skills, not memorizing thousands of problems.
Interview Schema
During preparation, every problem you solve — even if you already know the solution or have solved it before — practice speaking out loud. If you can’t speak out loud, simulate it in your head and walk through your reasoning as if you were talking to an interviewer.
Write comments as placeholders at the start so you never forget a step:
/*
# 1. Understand the problem
# 2. Find edge cases
# 3. Propose several solutions
# 4. Implementation
# 5. Testing
# 6. Analysis
*/
1. Understand the Problem
Ask clarification questions, even for things that seem obvious. It has happened to many people — myself included — that after starting to implement, they realize the whole approach was wrong because of a misunderstood requirement.
At the end of this step, summarize what you understood and confirm it with the interviewer. This builds trust and prevents wasted effort.
2. Find Edge Cases
Think through any boundary or corner case before writing code:
- Numbers: 0, negative, very large integers
- Arrays: null, empty, fewer items than required
- Strings: null, empty, very short, special characters
- Matrices: null, empty, irregular dimensions
- Trees / Linked Lists: null root, single node, circular structures
- Problem-specific: values that break your invariants
3. Propose Several Solutions
This is the most critical step. Always start with the brute force or the first idea that comes to mind — even if you already know a better one. It shows structured thinking.
Then look for improvements:
- Can you reduce time complexity with a different data structure?
- Can you eliminate redundant passes?
- Can you trade memory for speed or vice versa?
If you’re stuck, ask for a hint. It is not a failure — it shows collaboration. Use concrete examples and test cases to unlock your thinking; different inputs often reveal the pattern.
Pick the best solution you found. If it is not optimal, explain why and what the optimal would look like.
4. Implementation
Write the code. If you get stuck, go back to your test cases and trace through the algorithm step by step.
Keep talking during implementation. Explain what you are doing and why. If you need a quiet moment to think, say so — “Give me a moment to think through this.” Silence without warning feels awkward to an interviewer.
The interview does not just measure problem-solving skills — it measures communication and the ability to work with others.
Training on a whiteboard or on LeetCode’s editor (no autocomplete) is especially useful, as it mimics the actual interview environment.
5. Testing
Finishing the code does not mean you are done. Run through a few test cases manually:
- A normal, representative case
- One or two of the edge cases you identified earlier
- Trace through your code line by line — do not just read it
Catching your own bugs before the interviewer does makes a strong impression.
6. Analysis
Discuss your solution:
- Time complexity: What is the Big O? Why?
- Space complexity: What extra memory are you using?
- Is it optimal? If not, what would the optimal approach look like and what are the trade-offs?
Training
You cannot and should not try to solve every problem on LeetCode or HackerRank. Random practice without structure is hard to scale, and you will never get a representative sample of problem types. The good news: free resources are enough for most interviews.
LeetCode Top Interview Questions
Start with LeetCode’s Top Interview Questions list, available for free under the Explore section. It is curated, well-balanced, and a great baseline.
Always apply the interview schema above — even for problems you know. If you force the habit in practice, it will come naturally in the actual interview.
Train by Pattern
Inspired by this YouTube video, the most effective way to prepare is to train on specific patterns rather than random problems. Once you recognize a pattern, a whole class of problems becomes familiar.
1. Prefix Sum
Precompute cumulative sums for O(1) range queries.
2. Two Pointers
Use two indices moving toward or away from each other to avoid nested loops.
3. Sliding Window
Maintain a dynamic window over an array or string to find subarrays/substrings that meet a condition.
- 643 Maximum Average Subarray I
- 3 Longest Substring Without Repeating Characters
- 76 Minimum Window Substring
4. Fast & Slow Pointers
Two pointers moving at different speeds — useful for cycle detection and finding midpoints in linked lists.
5. Linked List In-Place Reversal
Reverse a linked list or a portion of it without extra space.
6. Monotonic Stack
Use a stack that maintains elements in monotone order to find next greater/smaller elements efficiently.
7. Top K Elements
Use a heap to efficiently track the K largest or smallest elements without full sorting.
8. Overlapping Intervals
Sort intervals and merge or insert by comparing start/end boundaries.
9. Modified Binary Search
Apply binary search beyond sorted arrays — on rotated arrays, answer spaces, or monotone functions.
others
- 704 Binary Search
- 162 Find Peak Element
10. Binary Tree Traversal
Master all traversal orders: inorder, preorder, postorder, and level-order (BFS).
- 257 Binary Tree Paths
- 230 Kth Smallest Element in a BST
- 124 Binary Tree Maximum Path Sum
- 107 Binary Tree Level Order Traversal II
others
- 94 Binary Tree Inorder Traversal
- 104 Maximum Depth of Binary Tree
- 102 Binary Tree Level Order Traversal
11. Depth-First Search (DFS)
Explore as deep as possible before backtracking — applies to trees and graphs.
- 133 Clone Graph
- 113 Path Sum II
- 210 Course Schedule II
others
- 112 Path Sum
- 200 Number of Islands
- 695 Max Area of Island
12. Breadth-First Search (BFS)
Explore level by level — ideal for shortest path and layer-by-layer problems.
13. Matrix Traversal
Apply DFS or BFS on a 2D grid, treating each cell as a node.
- 733 Flood Fill
- 130 Surrounded Regions
- 200 Number of Islands
others
- 79 Word Search
14. Backtracking
Explore all possible paths by building candidates incrementally and pruning invalid ones.
- 78 Subsets
- 46 Permutations
- 51 N-Queens
others
15. Dynamic Programming
Break problems into overlapping subproblems, store results to avoid recomputation.
- 70 Climbing Stairs
- 322 Coin Change
- 300 Longest Increasing Subsequence
- 416 Partition Equal Subset Sum
- 1143 Longest Common Subsequence
- 312 Burst Balloons
Summary
Following this schema consistently during practice is what builds the muscle memory needed for actual interviews. Harder roles — senior positions or top-tier companies — may require going deeper into each pattern and exploring advanced topics.
If you want to go further, these books are highly recommended:
- Cracking the Coding Interview by Gayle Laakmann McDowell — the classic reference for interview preparation
- Introduction to Algorithms (CLRS) — rigorous algorithms and data structures reference