Coding Round Mastery

Problem-Solving Process

4 min read

Knowing algorithms is necessary but not sufficient. You need a reliable process for solving problems under interview pressure. This five-step process works every time.

The 5-Step Process

Step 1: Understand the Problem (2-3 minutes)

Before writing any code:

  • Restate the problem in your own words to confirm understanding
  • Ask clarifying questions: Input size? Edge cases? Data types? Sorted?
  • Identify constraints: Time complexity target? Space constraints?

Key Questions to Ask:

  • "Can the input contain duplicates?"
  • "Is the input sorted?"
  • "What should I return for empty input?"
  • "Can values be negative?"
  • "What's the expected input size?"

Step 2: Work Through Examples (2 minutes)

Write out 2-3 examples by hand:

  • Normal case: Typical input
  • Edge case: Empty input, single element, all same values
  • Large case: Think about what happens at scale
Problem: Find two numbers that add up to target
Example 1: nums = [2, 7, 11, 15], target = 9 → [0, 1]
Example 2: nums = [3, 3], target = 6 → [0, 1]
Edge case: nums = [1], target = 2 → no solution

Step 3: Brute Force First (2 minutes)

Always start with the obvious solution, even if it's slow:

# Brute force: O(n^2)
def two_sum_brute(nums, target):
    for i in range(len(nums)):
        for j in range(i + 1, len(nums)):
            if nums[i] + nums[j] == target:
                return [i, j]

Why brute force first?

  1. Shows you understand the problem
  2. Gives you a baseline to optimize
  3. Sometimes brute force IS the answer
  4. Shows clear thinking under pressure

Step 4: Optimize (5 minutes)

Think about which pattern applies:

  • Can a hash map reduce O(n^2) to O(n)?
  • Is the data sorted? Can I use binary search?
  • Is there a sliding window opportunity?
  • Does this have overlapping subproblems (DP)?
# Optimized: O(n) with hash map
def two_sum(nums, target):
    seen = {}
    for i, num in enumerate(nums):
        complement = target - num
        if complement in seen:
            return [seen[complement], i]
        seen[num] = i

Communicate the optimization:

"The brute force is O(n^2) because of the nested loop. I can use a hash map to store values I've seen, reducing the inner lookup to O(1), making it O(n) overall."

Step 5: Code and Test (15-20 minutes)

Write clean code, then test:

  1. Code it up with clear variable names
  2. Trace through your example by hand
  3. Test edge cases: empty array, single element, no solution
  4. Analyze complexity: State time and space complexity

Time Management

For a typical 45-minute coding round:

Activity Time Notes
Understand + Examples 5 min Don't rush this
Brute Force 2 min Just describe it, don't code
Optimize 5 min Identify the pattern
Code 15 min Write clean, working code
Test + Debug 10 min Trace through examples
Discussion 8 min Complexity, alternatives, follow-ups

Handling Being Stuck

If you can't see the optimal approach:

  1. Talk through what you know: "I can see the brute force is O(n^2). I'm thinking about what data structure could speed up the lookup..."
  2. Think about related problems: "This reminds me of the sliding window pattern..."
  3. Reduce the problem: "What if the array were sorted? Then I could use..."
  4. Ask for a hint: Better to ask than sit in silence. Interviewers expect this.

Interview Tip: Silence is your enemy. Always verbalize your thought process. Interviewers are evaluating how you think, not just the final answer.


Next, let's cover how to write clean, impressive code during interviews. :::

Quiz

Module 5 Quiz: Coding Round Mastery

Take Quiz