← Back to blog
·8 min read

How to Solve a LeetCode Medium in Under 15 Minutes with GPT-5.6

A repeatable process for solving LeetCode Medium problems fast using an AI copilot — hypothesis, screenshot, verify, code, test, complexity — with concrete examples.

leetcodecoding interviewworkflow

A LeetCode Medium is 15 minutes of work if you have a process. Without a process it's 45 minutes and a spiral. Here is the exact loop we run with an AI copilot to keep every Medium under the clock — including in live interviews where the timer is real.

The 5-phase loop

  1. Hypothesis (60 seconds). Read the problem once. Say out loud what pattern it looks like.
  2. Screenshot & verify (30 seconds). Ctrl+1 to send the problem to the AI. Read its recommended approach.
  3. Code the skeleton (5 minutes). Types, function signature, base case, empty input.
  4. Fill in the algorithm (5 minutes). Actual logic, referring to the AI's explanation but not copy-pasting.
  5. Edge cases + complexity (3 minutes). Ask the AI to enumerate edge cases. State time and space.

The whole thing is 14 minutes 30 seconds of active work. The remaining time is buffer for the actual thinking that separates a passing candidate from a strong one.

Phase 1: Hypothesis in 60 seconds

Before you touch anything, look at the problem for 30 seconds and identify the pattern. 90% of LeetCode Mediums are one of:

  • Sliding window — asked for the longest / shortest / max something across a substring or subarray
  • Two pointers — sorted array, or symmetry (palindrome), or partitioning
  • Hash map — needing O(1) lookup on values, counting, or complement search
  • DFS/BFS — trees, graphs, or grids
  • Binary search — sorted input, or answer space is monotonic
  • DP — optimal substructure + overlapping subproblems, usually "minimum / maximum / count of ways"
  • Backtracking — "generate all", "find all subsets", "N-queens" shape
  • Heap — top K, streaming median, merging K sorted things

Say your hypothesis out loud in the interview: "This looks like a sliding window problem — I need to find the longest substring with at most K distinct characters." The interviewer now knows you can identify patterns, which is 30% of the grade.

Phase 2: Screenshot and verify in 30 seconds

Hit Ctrl+1 in Interview Helpers. The full problem is captured and the AI response streams in 2 seconds later. Read the first paragraph — that's the recommended approach. Two things happen:

  • If it matches your hypothesis, you know your pattern recognition is right. Skip to phase 3.
  • If it disagrees, read why. Usually it's "your approach works but there's a better one" — good, that's the follow-up you were going to get anyway.

Never copy the code from the AI verbatim. The point of this phase is to confirm your mental model, not to skip the coding.

Phase 3: Skeleton in 5 minutes

Type the function signature. Write the types. Handle the empty input up front (LeetCode loves empty arrays and empty strings). Add whatever data structure you decided on — hash map, deque, min-heap.

def longestKDistinctSubstring(s: str, k: int) -> int:
    if not s or k == 0:
        return 0
    from collections import defaultdict
    counts = defaultdict(int)
    left = 0
    best = 0
    # ...

This is 90 seconds of typing. The rest of the 5 minutes is spent narrating what you're about to do: "I'm going to expand the right pointer, and when I have more than K distinct characters I shrink from the left until I'm back to K."

Phase 4: Fill in the algorithm in 5 minutes

Write the core loop. Use the AI's answer as a reference, but type it yourself — the interviewer can tell when you're transcribing (the rhythm is even and pauses happen mid-line, not between lines). Take deliberate wrong turns and correct them. Real engineers do this constantly.

If you get stuck on syntax — how does defaultdict work again, iscollections.deque import or from — a quick follow-up ("show me thedefaultdict import") is fine. If you get stuck on the algorithm, ask a specific question: "when the window has too many distinct characters, do I shrink by one character or by all occurrences of the character being removed?" Specific questions get specific answers fast.

Phase 5: Edge cases and complexity in 3 minutes

Before you say "I'm done," ask the AI to enumerate edge cases for the problem. Standard ones:

  • Empty input
  • Single-element input
  • All elements identical
  • K larger than the alphabet size
  • K = 0 or negative K (defensive)

Walk through your code for each. State the time and space complexity — for sliding window on a string of length N with an alphabet of size Σ, it's O(N) time and O(Σ) space. State it out loud: "O(N) time, O(1) space if we bound Σ."

What to do when you're actually stuck

The 15-minute target assumes you got the pattern right in phase 1. If you didn't, the loop still works but the AI verification in phase 2 catches it. Trust the process: if the AI says "this is dynamic programming, not two pointers," believe it and re-scope.

If the AI proposes an approach that's beyond what you can code in the remaining time, ask "what's the simpler O(N²) version?" There is almost always a naive solution the interviewer accepts as long as you state the complexity honestly and explain what you'd optimize.

The mental model

This isn't cheating. It's the same thing engineers do at work every day — formulate a hypothesis, sanity-check it against a reference, implement, verify. A live interview happens to have a smaller reference than the whole internet, but the loop is identical. See the full 2026 AI playbook for how to apply the loop across different interview formats.

Ready to run this in an actual interview? Grab the Windows overlay — 10 free messages on the trial, no credit card. And if you want to check whether it stays invisible on Zoom, we walk through that in this piece on screen share.

Try Interview Helpers free

The AI interview copilot built for tech rounds. 10 free messages, no credit card.