Interval Duration
You are given a two-dimensional list of integers intervals where each list represents an inclusive [start, end] interval.
Return the total unique duration it covers.
Constraints
n ≤ 100,000wherenis length ofintervals.
https://binarysearch.com/problems/Interval-Duration
Examples
Example 1
Input
- intervals =
[[45,60],
[ 1, 5],
[ 5,15],
[ 2, 3]]
Output
- answer =
31
Explanation
The total unique covered distance is [45, 60] (duration of 16) and [1 ,15] (duration of 15).
Leave a comment