Google | Bangalore | Intervals Problem
Anonymous User
2020

Given an array of half open intervals [A....B). This interval represents segments on the number line.
We need to paint each of this segments and return size of the interval that has not been painted with previous interval. We need to return an array as an O/P, each element i in the array represents the size of unpainted segment for ith interval.

Example:
[1, 10], [8, 14]
O/P: [9, 4]

Explanation:
In first interval nothing is painted so we will paint the entire interval, so the answer would be 9. When the second interval comes in part of the interval [8, 10) has already been painted, so now we only need to paint interval [10, 14) so our answer would be 3.

Comments (6)