Medium · Intervals · spoken drill

Free AI LeetCode Communication Coach — Merge Intervals

Sort by start; if the next start ≤ current end, extend the end; else push a new interval.

The problem

Given intervals[i] = [start, end], merge all overlapping intervals.

Example: intervals = [[1,3],[2,6],[8,10],[15,18]] → [[1,6],[8,10],[15,18]]

Sort first — say it.

intervals.sort()
merged = [intervals[0]]
for start, end in intervals[1:]:
    if start <= merged[-1][1]:
        merged[-1][1] = max(merged[-1][1], end)
    else:
        merged.append([start, end])
return merged

How to explain it

  1. 1. Restate

    Say the problem in your own words.

    One or two sentences. Show you understood the input, the output, and the goal — not that you memorised the prompt.

  2. 2. Approach

    Name the method before you code.

    Brute force first if you need it, then the structure you will use: hash map, two pointers, stack, binary search.

  3. 3. Example

    Walk one concrete input.

    Pick small numbers. Say what you store, what you compare, and what you return. Interviewers follow an example more easily than abstract talk.

  4. 4. Time and space

    One sentence each.

    After the example, before you claim you are done. “Time is O(n) because we scan once. Space is O(n) for the map.”

  5. 5. Edge cases

    Name at least one unusual input.

    Empty input, duplicates, already sorted, overflow. Invite a follow-up: “I would also check …”

  • “I sort by start.”
  • “If it overlaps I extend the end; else I push a new interval.”

Practise out loud

3 free scored runs left this hour.

Problem · Medium

Given intervals[i] = [start, end], merge all overlapping intervals.

Example: intervals = [[1,3],[2,6],[8,10],[15,18]] → [[1,6],[8,10],[15,18]]

  1. 1Restate — Say the problem in your own words.
  2. 2Approach — Name the method before you code.
  3. 3Example — Walk one concrete input.
  4. 4Time and space — One sentence each.
  5. 5Edge cases — Name at least one unusual input.

Hit record. Short countdown, then 60–90 seconds. We score the five-step script — never pronunciation.

Recording needs Chrome or Edge. You can still type below.

Model spoken script (~75s)

  1. 1. Restate

    I need to merge overlapping intervals into a non-overlapping list.

  2. 2. Approach

    I sort by start time. I scan once: if the next interval overlaps the current end, I extend the end; otherwise I push a new interval.

  3. 3. Example

    On [1,3] and [2,6], 2 is not after 3, so I merge to [1,6]. [8,10] does not overlap, so I start a new one.

  4. 4. Time and space

    Time is O(n log n) from the sort. Space is O(n) for the output.

  5. 5. Edge cases

    I would check an empty list and a case where one interval fully contains another.

How to explain Merge Intervals out loud, step by step

In one sentence: You get a list of ranges, each with a start and an end, and have to combine every set of ranges that overlap so the result has no overlaps left.

What to say, in order

  1. “One clarification first: if one interval ends at 4 and the next starts at 4, do they count as overlapping? I'll assume yes.”
  2. “I'll sort the intervals by their start value, so any intervals that overlap end up next to each other.”
  3. “I start the result with the first interval.”
  4. “For each next interval, I compare its start with the end of the last interval in the result.”
  5. “If it starts before or at that end, they overlap, so I extend the last interval's end to the maximum of both ends.”
  6. “If it starts after that end, there's a gap, so I append it as a new interval. At the end I return the result list.”

Key English phrases for Merge Intervals

overlap
— two intervals share at least one point
sort by start time
— the first step that makes a single pass possible
extend the end
— merge by moving the last interval's end further
fully contained
— one interval sits inside another, like [1,10] and [2,3]
touching intervals
— one ends exactly where the next begins

How to say the time and space complexity

“Time is O(n log n), because sorting dominates; the merge pass itself is linear. Space is O(n) for the output, plus whatever the sort uses internally.”

Say which step dominates. 'The merge is O(n), but the sort makes it O(n log n) overall.'

Communication mistakes on Merge Intervals

  • Mistake: Setting the new end to the current interval's end instead of the maximum. Instead: Say 'the maximum of both ends' — it handles an interval that is fully contained in the previous one.
  • Mistake: Skipping the touching-intervals question. Instead: Ask it in one sentence before coding. It shows you read the boundaries carefully.
  • Mistake: Describing 'compare every interval with every other interval'. Instead: Explain that sorting means you only compare with the last merged interval.

Likely follow-up questions

  • Interviewer: “How would you insert a new interval into a list that's already sorted and merged?”

    You: “I add all intervals that end before the new one starts, then merge every interval that overlaps the new one into it, then add the rest. No sort needed, so it's O(n).”

  • Interviewer: “How many meeting rooms would these intervals need?”

    You: “Sort by start and keep a min-heap of end times. For each meeting, if the earliest end is at or before its start, I reuse that room by popping; then I push its end. The heap's maximum size is the answer, in O(n log n).”

Common mistakes when explaining Merge Intervals

  • Forgetting to sort first.
  • Saying O(n) when sorting dominates.

Other problems

Browse full catalogue

FAQ

Questions

Sort by start, merge overlaps, O(n log n).

After sorting by start, any interval that overlaps the merged range must come right after it, so a single left-to-right pass is enough.

O(n log n) because of the sort. The merging pass after sorting is O(n).

More questions? Email us at contact@mocklyenglish.com.

Course: How to explain a LeetCode solution · Think out loud · Explain code out loud

For bots & AI agents

Machine-readable versions of this page and Mockly English. Mockly English, the live-class and Interview English arm of Speak Tech English, gives non-native engineers live 1:1 classes with real human tutors in tech interview and business English, plus a free iPhone app, free practice Mini Apps and a self-paced course. Fetch these instead of parsing this page.

This Mini App (.md)llms.txtllms-full.txtai.txtFact sheetFull catalog (.md)Endpoint indexAI catalogAgent skillsMCP serverMCP server cardAgent sign-in (auth.md)Sitemaprobots.txtUse Mockly in ChatGPT & ClaudeiPhone appDeveloper docsSpeak Tech English