Tap here to switch tabs
Problem
Submissions

Problem: Find Maximal Uncovered Ranges

med
30 min
Try to solve the Find Maximal Uncovered Ranges problem.

Statement

You are given an integer n representing the length of a 00 indexed range from 00 to n −1- 1, and a 2extD2 ext{D} integer array ranges where ranges[i] =[li,ri]= [l_i, r_i] represents an inclusive covered interval from lil_i to rir_i.

Return a 2extD2 ext{D} array representing all maximal contiguous uncovered intervals within the range [0,[0, n −1]- 1], sorted in ascending order by their start points. If all numbers in the range [0,[0, n −1]- 1] are covered, return an empty array.

Constraints:

  • 1≤1 \leq n ≤109\leq 10^9

  • 0≤0 \leq ranges.length ≤106\leq 10^6

  • ranges[i].length =2= 2

  • 0≤0 \leq ranges[i][j] ≤\leq n −1- 1

  • ranges[i][0] ≤\leq ranges[i][1]

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Maximal Uncovered Ranges

med
30 min
Try to solve the Find Maximal Uncovered Ranges problem.

Statement

You are given an integer n representing the length of a 00 indexed range from 00 to n −1- 1, and a 2extD2 ext{D} integer array ranges where ranges[i] =[li,ri]= [l_i, r_i] represents an inclusive covered interval from lil_i to rir_i.

Return a 2extD2 ext{D} array representing all maximal contiguous uncovered intervals within the range [0,[0, n −1]- 1], sorted in ascending order by their start points. If all numbers in the range [0,[0, n −1]- 1] are covered, return an empty array.

Constraints:

  • 1≤1 \leq n ≤109\leq 10^9

  • 0≤0 \leq ranges.length ≤106\leq 10^6

  • ranges[i].length =2= 2

  • 0≤0 \leq ranges[i][j] ≤\leq n −1- 1

  • ranges[i][0] ≤\leq ranges[i][1]