Following must work:
- Sort all your time values and save Start or End state for each time value.
- Set
numberOfCallsto 0 (count variable) -
Run through your time values and:
- increment numberOfCalls if time value marked as Start
- decrement numberOfCalls if time value marked as End
- keep track of maximum value of numberOfCalls during the process (and time values when it occurs)
Complexity: O(n log(n)) for sorting, O(n) to run through all records