Medium · Intervals

Count Intervals Range

Given a list of inclusive integer intervals [start, end] in any order, return the number of distinct integers covered by at least one interval.

Examples

Example 1

[1,3] [2,6] [8,10] [9,11]

Output: 10 covered

Example 2

[1,2] [3,4] [6,7]

Output: 6 covered

Rebuild it in the studio

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Intervals problems