Loading...
You are given a 2D integer array intervals, where intervals[i] = [start, end] covers every integer coordinate from start to end inclusive.
Return how many distinct integer coordinates are covered by at least one interval. Coordinates covered by several intervals are counted once.
Input: intervals = [[3,6],[1,5],[4,7]]
Output: 7
Explanation: Together the intervals cover the coordinates 1 through 7, so 7 coordinates are covered. The overlaps at 3, 4, 5, and 6 do not add to the count.
Input: intervals = [[1,3],[5,8]]
Output: 7
Explanation: The first covers 1, 2, 3 and the second covers 5, 6, 7, 8. Coordinate 4 is covered by neither, so the total is 3 + 4 = 7.
intervals.length ≤100intervals[i].length =2start ≤ end ≤100Click "Run" to test with sample cases or "Submit" to run all tests.