FastPrepRunning Interval Union Length

Running Interval Union Length

Google logoGoogle● MediumINTERNONSITE INTERVIEW

Problem statement

Intervals arrive one at a time in uploads. Each row [left, right] represents the half-open interval [left, right).

The problem statement continues
Pro

Examples

Example 1

uploads = [[1,5],[7,10],[3,8],[8,9]]return = [4,7,9,9]

The first two intervals cover lengths 4 and 3. Uploading [3,8) joins them into [1,10), whose length is 9. The final interval is already covered.

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
  • 1 more worked example, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
See Google hiring insights
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
  • 1 more worked example, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week