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

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Intervals problems