Problem · Array

Intersect Multiple Interval Lists

HardGoogle logoGoogleFULLTIMEONSITE INTERVIEW
See Google hiring insights

Problem statement

You are given intervalLists, an array of lists of closed integer intervals. An interval [start, end] includes both endpoints. A list may be unsorted and may contain overlapping intervals.

First normalize every list by sorting and merging its overlapping intervals. Then return all maximal nonempty closed intervals that occur in every normalized list, sorted by start.

The problem statement continues
Pro

Examples

Example 1

intervalLists = [[[0,2],[5,10],[13,23]],[[1,5],[8,12],[15,24]]]return = [[1,2],[5,5],[8,10],[15,23]]

The result contains every closed overlap shared by the two lists, including the single-point interval [5,5].

FastPrep Pro
Reported in 1 Google interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$9/month

Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Google interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$9/month

Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week