You have a sorted list of intervals (sorted by start time). There are two constraints:
a. There are millions of intervals in this list.
b. The total range covered by these intervals is also very large - more than 10^6
Question:
Example : [10-30], [15-35], [20-40], [25-30] and k = 3
there is a conflict because at t=25 we have 4 intervals.
Approach suggested: find the min and max of the interval range and declare an array of this size. For each interval, mark the range (i.e increase it by 1). When incrementing the range if any value becomes more than 'k', it is a conflict.
Time complexity : O(n * |L|) - where |L| is the max interval size.
Interviewer was not satisfied with this response and wanted a better/efficient approach.
Any suggestions?