I have numerical segments. For example:
segmetns = [[10,25],[75,270],[11,32],[50,111]]
My task is to count the number of points not occupied by segments.
32-50 in the current situation do not have segments.
I think to implement it with a dictionary. Take the minimum and maximum on the segments (this is easy to get) and replace values in the dictionary if their key is in the range. But I will have to go along the entire length of each of the segments. It is not profitable in time, because segments can be greater than 1 * 10 ^ 12.
Maybe there is the possibility of replacing the range of keys without changing each.