← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Google SWE interview, got a merge intervals problem. Pretty standard algorithmic round, nothing too wild to report.

Questions Asked (1)

Q1

Given a list of intervals, merge all overlapping intervals and return the resulting list.

Algorithms & Data Structures
Author's notes

Classic problem but I still fumbled the edge case where one interval completely swallows the next.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (e.g., whether intervals are sorted, inclusive/exclusive boundaries, and expected output format). Then propose an efficient algorithm: sort intervals by start time and merge overlapping ones in a single pass. Walk through an example to demonstrate correctness and analyze time/space complexity.

Pro tip: Mention edge cases upfront (empty input, single interval, all overlapping, no overlaps) and discuss how your solution handles them. This shows thoroughness and often impresses interviewers at top companies like Google.

1. Clarify requirements and constraints

Ask about input size, whether intervals are sorted, boundary conditions (inclusive/exclusive), and expected output format. Confirm if intervals are given as pairs [start, end].

2. Propose a high-level approach

Explain that sorting by start time allows merging in a single pass. Mention that this reduces the problem to comparing each interval with the last merged one.

3. Detail the algorithm

Describe: sort intervals by start; initialize result with first interval; for each subsequent interval, if it overlaps with the last in result, merge by updating the end to max of both ends; else append it.

4. Analyze complexity and edge cases

State time complexity O(n log n) due to sorting, space O(n) for output (or O(log n) if in-place). Discuss edge cases: empty list, single interval, intervals with same start, touching intervals (end == start).

5. Test with examples

Walk through a simple example (e.g., [[1,3],[2,6],[8,10],[15,18]]) to show merging. Also test edge cases like [[1,4],[4,5]] to clarify if touching intervals merge (depends on definition).

Key Points to Mention

  • Sorting intervals by start time is key to achieving O(n log n) time complexity.
  • Merging condition: if current interval's start <= last merged interval's end, they overlap.
  • When merging, update the end to the maximum of the two ends to handle nested intervals.
  • Edge cases: empty input, single interval, all intervals overlapping, no overlaps, and intervals that just touch.
  • Space complexity: O(n) for the output list; can be O(1) extra if merging in-place (but sorting may require extra space).
  • Clarify whether intervals are closed [start, end] or half-open; this affects whether touching intervals merge.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.