Fewest railway platforms
N trains stop at a station on the same day; each has an arrival and a departure time (HH:MM). A train uses a platform from its arrival minute to its departure minute, both included, so a train arriving at the minute another leaves needs a different platform. Find the fewest platforms needed.
Input
First line: N. Next N lines: arrival and departure times.
Output
The fewest platforms.
Constraints
1 ≤ N ≤ 10^5; times are from 00:00 to 23:59 and departure is not before arrival.
Example 1
Input:
3
09:00 09:10
09:05 09:20
09:15 09:30
Output:
2Example 2
Input:
2
10:00 10:30
10:30 11:00
Output:
2Example 3
Input:
4
06:00 06:05
07:00 07:10
08:00 08:00
09:00 09:01
Output:
1Hint: Turn each train into two events: +1 at arrival and −1 just after departure. Sort the events (an arrival comes before a departure at the same minute) and track the running total; its maximum is the answer.