Вот рабочий алгоритм на Python
def maximumOverlap(calls):
times = []
for call in calls:
startTime, endTime = call
times.append((startTime, 'start'))
times.append((endTime, 'end'))
times = sorted(times)
count = 0
maxCount = 0
for time in times:
if time[1] == 'start':
count += 1 # increment on arrival/start
else:
count -= 1 # decrement on departure/end
maxCount = max(count, maxCount) # maintain maximum
return maxCount
calls = [
('2:22:22 PM', '2:22:33 PM'),
('2:22:35 PM', '2:22:42 PM'),
('2:22:36 PM', '2:22:43 PM'),
('2:22:46 PM', '2:22:54 PM'),
('2:22:49 PM', '2:27:21 PM'),
('2:22:57 PM', '2:23:03 PM'),
('2:23:29 PM', '2:23:40 PM'),
('2:24:08 PM', '2:24:14 PM'),
('2:27:37 PM', '2:39:14 PM'),
('2:27:47 PM', '2:27:55 PM'),
('2:29:04 PM', '2:29:26 PM'),
('2:29:31 PM', '2:29:43 PM'),
('2:29:45 PM', '2:30:10 PM'),
]
print(maximumOverlap(calls))