Back to Google
Google logo

Coding rounds

Google coding rounds

5 timed coding challenges drawn from real loops. Submit a solution to see your test pass rate and AI feedback.

All coding rounds
intermediate 40:00+80 XP

Merge Intervals

Given an array of `intervals` where `intervals[i] = [start, end]`, merge all overlapping intervals and return an array of the non-overlapping intervals that cover all the intervals in the input. Sort by start, then sweep.

Examples

  • [1,3] and [2,6] overlap

    in: [[1,3],[2,6],[8,10],[15,18]]

    out: [[1,6],[8,10],[15,18]]

  • touching intervals merge

    in: [[1,4],[4,5]]

    out: [[1,5]]

javascript
Loading editor...