Skip to main content

Guide · coding-prep

How to Handle a Coding Problem You've Never Seen Before

Don't pretend it looks familiar. Restate it, simplify it, solve a smaller version, then scale up. Most 'hard' coding-interview problems are just two known patterns stitched together, and the pattern fit only becomes visible after you've worked one tiny example by hand.

By , Founder, InterviewChamp.AI · Last updated

TL;DR: Don't start coding. Restate the problem in your own words, trace a 3-5 element example by hand, say the brute force and its time complexity, and only then map what you traced to a known pattern (or two patterns stitched together). If you're still stuck, solve n=1 and n=2, find what changes at n=3, and ask for a hint with a specific direction instead of going quiet.

How do you handle a coding problem you've never seen before?#

Hold off on the code. Put the problem into your own words, work one tiny concrete example by hand, and then grow that solution. Many "novel" coding-interview problems are two known patterns stitched together, and you usually only see the fit after a real example is sitting in front of you. Working backward from a small case is what works. Pulling a pattern out of memory, honestly, rarely does.

That restate-and-shrink habit is what gets you the offer that ends a months-long search. It lets you explain the answer in your own voice instead of reciting a solution you half-remember.

It also travels well. A remote phone screen on a shared editor, a FAANG onsite at a whiteboard, a timed screen on HackerRank, CodeSignal, or CoderPad: the unfamiliar problem lands the same way in each one. If you want to feel it before it counts, run a practice round and hear yourself work an unfamiliar problem out loud first so the live version isn't your first time. Wherever you end up, it's worth knowing which language to use in a coding interview, because being fluent in it is what lets you talk through a strange problem calmly.

The 4-step unfamiliar-problem protocol, plus one fallback#

Run these four steps in order every time a problem looks foreign, and keep one fallback ready for when they stall. It takes 5-7 minutes, and it saves you from spending 25 coding the wrong thing.

Step 1: Restate it in your own words (60 seconds)

Paraphrase the ask. Don't read the prompt back word for word. Something like: "So I have a list of meetings, each with a start and end time, and I want the maximum number running in parallel at any single moment."

Then ask the clarifying questions that change the answer, such as input bounds and edge cases (more on those below). Misreads get caught here, and that's where most "I solved the wrong problem" stories start.

Step 2: Work a 3-5 element example by hand (2-3 minutes)

Pick a small concrete case and trace it on paper or the whiteboard. Not in your head. Writing it out while you talk ("okay, meeting A is 1-5, B is 2-3, C is 4-7...") shows you structure that your brain just can't see while staring at the prompt.

Step 3: Ask whether the brute force is acceptable (30 seconds)

Say the obvious approach out loud: "For each minute in the time range, count the active meetings. That's O(time × n). If time is bounded, that's fine. Is the input size bounded?"

Often the interviewer says "no, do better." Sometimes it's "yes, that's fine for now, but show me the optimization too." Either answer is gold, because it tells you exactly how far you need to go. A brute-force solution is the most direct approach you know is correct, regardless of efficiency. On an unfamiliar problem it's a tool, not an admission of defeat: it gives you a correct baseline and often shows the structure the optimized version will use. Time complexity is how an algorithm's running time grows with input size, written in Big-O notation, and naming it out loud is how you and the interviewer decide whether that baseline is good enough. Once you have it, here's how to explain a coding solution in a technical interview, from the brute force through the optimization and a final trace.

Step 4: Map the worked example to a known pattern

Once the example is traced, you'll usually notice it looks like one of these: two-pointer, sliding window, sweep line, monotonic stack, BFS/DFS, dynamic programming on a small state, or binary search on the answer. If you can say "this feels like a sweep-line problem because..." you're most of the way to the solution.

The fallback: if the trace still doesn't suggest a pattern, shrink the problem, as the section on solving the smallest possible version below shows.

Steps 1 and 2 are the ones new grads skip under pressure. They're also the two that matter most. For the narration habit that makes each step clear to the interviewer, pair this with how to think aloud during a coding interview.

I'd skip any fancier framework than four steps and one fallback. Under a clock, more steps just means more things to drop.

A worked example: maximum meetings in parallel#

Here's the protocol on the meetings problem from above, start to finish, so you can see how each step feeds the next one.

Restate. "I get a list of meetings with start and end times. I return the largest number that overlap at any one moment."

Clarify. Before tracing, ask the questions that change the answer. If one meeting ends at 5 and another starts at 5, do they overlap? Can the list be empty? Are the times whole numbers? Each answer shapes the code you'll write later.

Trace. Take A = 1-5, B = 2-3, C = 4-7. Walk the timeline: at time 2, A and B are both running, so the count is 2. B ends at 3, dropping it to 1. C starts at 4 while A is still going, back to 2. A ends at 5, then C ends at 7. The answer is 2.

Brute force. Check every minute and count active meetings. That's the O(time × n) approach from Step 3. It's correct, and it's a fine baseline if the time range is small.

Map. Look at what your trace was doing. You only cared about the moments something started or ended, and you kept a running count. That's a sweep line: turn each meeting into a start event and an end event, sort them, and walk through keeping a tally.

Code. A short Python version:

def max_parallel_meetings(meetings):
    events = []
    for start, end in meetings:
        events.append((start, 1))   # a meeting begins
        events.append((end, -1))    # a meeting finishes
    # at equal times, -1 sorts before 1, so a meeting that ends at 5
    # is closed before one that starts at 5 is opened
    events.sort()
    running = 0
    best = 0
    for _, change in events:
        running += change
        best = max(best, running)
    return best

Notice the comment on sorting. That one line is where your clarifying question about touching meetings shows up in the code. If the interviewer had said meetings at the same time do overlap, you'd flip the tie order.

Test. The protocol doesn't end when the code is written. Walk your own trace through it line by line, out loud, tracking running and best as you go: A, B, C should give 2. Then try the edge cases you asked about while clarifying: an empty list gives 0, one meeting gives 1, and two meetings that touch at 5 give 1 with this tie rule.

If a case breaks, fix that spot and say what you changed. Don't wipe the board and start over. A calm, local fix shows the interviewer you can debug. A full restart mostly shows that you panicked.

Restate vs. pattern-match: which to do first#

Order of operations is the whole game here. Most candidates flip it. They grab a remembered pattern before they understand the problem, and that move is what gets strong people downgraded. The contrast looks like this:

| Move | When the unprepared candidate does it | When the strong candidate does it | What the interviewer reads | |---|---|---|---| | Reach for a remembered pattern | First, before understanding the prompt | Last, after a worked example | First: panic-matching. Last: pattern fluency | | Restate the problem in own words | Skipped; they echo the prompt | First, in the opening 60 seconds | Comprehension before code | | Work a 3-5 element example by hand | Rarely, and only in their head | Early, on the whiteboard, out loud | Concrete reasoning, not bluffing | | Ask if the brute force is acceptable | Never; assumes optimal is required | Before optimizing anything | Pragmatism and scoping sense | | Shrink to n=1, n=2 | Freezes instead | When the worked example stalls | Composure under an unfamiliar prompt |

Read it top to bottom and the lesson fits in one line. Understanding comes first, and the pattern comes last.

Why pattern-matching from memory fails#

Trying to name the pattern before working the example is the most common new-grad mistake on hard problems. You scan your memory ("I've seen this... was it the activity selection one? the meeting rooms one?"). Then one of two things happens. You find a near-match and try to force it onto the new problem, which is often wrong, or you don't find one and freeze.

The fix is to flip the order. Work the example first. Then ask "what pattern does this concrete trace look like?" Pattern recognition runs faster on a worked example than on a problem statement. Force-fitting is how a candidate ends up writing an O(n²) answer when the trace pointed to an O(n) one, or solving a slightly different problem from the one asked. Levels.fyi's blog has more interview debriefs if you want to read how these rounds go.

Solve the smallest possible version#

Sometimes even the worked example doesn't suggest anything. Then shrink further. Solve n=1 and n=2 by inspection, and ask: "what changes when I go from n=2 to n=3?"

That delta, the thing that makes n=3 harder than n=2, is almost always the core of the algorithm. A couple of examples:

  • For "merge intervals," the delta is did the new interval start before the previous one ended.
  • For "longest substring without repeating," it's did adding this character break uniqueness.

The pattern lives in the delta.

The "two-known-patterns" frame#

A problem that feels brand new is often two patterns you've already seen separately, combined into one. So once you've worked the example, look for two patterns that might fit together:

  • Binary search + greedy verification = "minimum capacity to ship in K days" family
  • Sliding window + hash map = "longest substring with K distinct" family
  • Sort + two pointer = "three-sum" family
  • DFS + memoization = "count paths in a grid with obstacles" family

A sliding window is a two-pointer technique that keeps a contiguous range over a sequence, growing and shrinking it to satisfy a constraint. It shows up in a large share of medium array and string problems, which is why it's worth spotting on sight.

When you say "this looks like a sort step followed by a two-pointer sweep" out loud, the interviewer will usually nod or redirect you. Either way, an unfamiliar problem has just turned into a familiar combination. For more on how interviews get harder at senior levels, the Pragmatic Engineer newsletter is worth reading.

If you want to drill these combinations instead of memorizing one-off solutions, the coding interview cheat sheet lists the core patterns. The LeetCode 75 vs Blind 75 vs NeetCode 150 breakdown tells you which problem set builds pattern fluency for the 2026 hiring cycle.

Don't forget the clarifying questions#

An unfamiliar problem is often just an under-specified one. Before you commit to an approach, pin down the input bounds, the edge cases, and the expected output for the weird inputs:

  • empty input
  • a single element
  • duplicates
  • negative numbers

Half the time, the answer to a clarifying question is the hint. The full set of moves is in how to handle clarifying questions on a coding problem. Run it before you start coding, not after.

If you're not sure what kind of question you've been handed, how to tell which type of technical interview question you're facing shows what each type is measuring. And if it turns out to be a quick concept check rather than a coding task, here's how to handle a CS fundamentals pop quiz without bluffing.

What to say when you're completely stuck#

After 8-10 minutes of honest effort with no traction, use this script:

"I haven't seen this pattern before. Here's what I've ruled out and why. Here's what I'd try next: [specific direction]. Does that direction make sense, or are you nudging me toward something else?"

That's a specific, testable request for a hint, and it beats a vague "I'm stuck" or silence. Interviewers want to see how you ask for help, and a precise ask is a signal on its own. For broader advice on handling pressure in interviews, the Indeed Career Guide's interviewing section is a good place to read more.

When you do get a hint, treat it as new information about the problem. Fold it into your trace and keep going from where you are.

The deeper version of this skill is staying composed when your first approach falls apart. If a solution collapses halfway through, recovering is its own discipline: see how to recover from a wrong solution mid-interview.

The candidates who walk out with the offer that ends the search aren't the ones who never get stuck. They're the ones who get unstuck out loud, in their own words. If you'd rather rehearse that exact moment until it's second nature, see how live coaching turns a shaky start into a clean finish. It starts free (60 minutes a month, no card), with Pro at $29 a month.

What not to do#

A short list of habits that undo the protocol:

  • Typing in the first minute. Code written before you've restated the problem is usually code for a different problem.
  • Tracing silently in your head. The interviewer can't follow it, and you'll miss things you'd catch on the board.
  • Hiding the brute force. Skipping it because it feels too simple throws away a correct baseline and a free clarifying question.

Building the reflex before interview day#

You can't learn this protocol live for the first time. As of 2026, the most reliable way to rehearse the unfamiliar case is to practice from a shuffled, untagged set so you can't cheat by category.

Pull a mixed batch of problems, hide the topic tags, and run each one end to end under a 30-minute timer: restate, trace, brute force, map. Solving every problem isn't the goal. Making the first 90 seconds automatic is, so a strange prompt kicks off the protocol instead of panic. If a strange prompt still makes your mind go blank, here's how to handle interview anxiety as a CS new grad, including a short reset line to use when you freeze.

Solo practice has a blind spot, though. You can't see your own stalls, and you never feel the pressure of a real person watching. That's where structured reps help. See how mock interview practice moves the needle for CS new grads for the format that builds composure, not just correctness.

Key terms#

Brute force: The most direct approach to a problem that you know is correct, ignoring efficiency. On an unfamiliar coding-interview problem it's a deliberate first step: it gives you a correct baseline and often exposes the structure the optimized solution will use.

Sliding window: A two-pointer technique that keeps a contiguous range over an array or string, growing and shrinking the range to satisfy a constraint. One of the most common patterns "novel" problems break down into.

Sweep line: An approach that processes events in sorted order along one axis (often start and end points), keeping a running tally as it goes. The classic fit for interval and scheduling problems like "maximum meetings in parallel."

Time complexity: How an algorithm's running time grows with input size, written in Big-O notation (for example O(n) or O(n log n)). Naming it out loud is how you decide whether the brute force is good enough or needs optimizing.

Pattern matching: Recognizing that a problem belongs to a known family (two-pointer, BFS, dynamic programming). It works far better on a worked example than on a raw problem statement, which is why you trace first and match second.


About the author: Sam K. is the founder of InterviewChamp.AI and writes about the modern tech interview from the inside: what changed, what works for new grads, and where the old playbook fails.

Originally published on InterviewChamp.AI

Frequently asked questions

What should I do in the first 60 seconds if I don't recognize the problem?
Don't code. Don't even reach for a pattern. Restate the problem in your own words, ask one clarifying question, and write down a 3-5 element example by hand. The pattern almost always reveals itself once you have a concrete instance in front of you.
What if I still don't see a pattern after working an example?
Solve the smallest possible version (n=1 or n=2) however you can. Often the brute-force solution for the tiny case shows you the structure of the general solution. If even the tiny case is unclear, you're misreading the problem, so go back and restate.
Is it okay to admit I haven't seen the problem before?
Yes, briefly. 'This isn't a pattern I recognize immediately, give me a minute to work through a small example' is fine. It beats pretending you've seen it and then visibly flailing. Honesty here scores higher than performed confidence.
How do I avoid panicking when the problem looks impossible?
Make it smaller. If a million-element input feels impossible, solve the three-element case by hand. Almost no interview problem is genuinely intractable in 30 minutes; it just looks that way at full scale. The smallest-version drill resets your panic baseline.
What if the interviewer pushed me toward a specific approach and it isn't clicking?
Ask one targeted question, not a vague 'can you help'. 'Are you nudging me toward sorting first?' is collaborative. 'I'm stuck' invites silence. Make the hint specific enough that they can confirm or redirect with one word.
How do you approach a coding interview problem you've never seen before?
Use a fixed protocol so you don't freeze: restate the problem, work a 3-5 element example by hand, check whether the brute force is acceptable, then map the worked example to a known pattern. Working a concrete example first is faster than scanning your memory for a remembered solution, because pattern recognition runs better on a trace than on a prompt.
Where can I find coding examples for interview practice on unfamiliar problems?
Practice from a mixed, untagged set so you can't pattern-match by category. That's the only way to rehearse the unfamiliar case. Pull problems from NeetCode 150, Blind 75, or LeetCode and shuffle them, then run each one out loud under a 30-minute timer as if it were live. The skill you're building is the restate-and-shrink protocol, not memorizing any single solution.