Minimum Cabs
Practice
4 (43 votes)
Algorithms
Easy
Greedy algorithms
Problem
89% Success 6357 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Assume there are N persons and each person needs exactly one cab. For each person, you are given the start time and end time (both inclusive) during which that person will travel. Find the minimum number of cabs required.

Input:
First line contains an integer, N \((1 \le N \le 10^5)\) denoting the number of persons. Next N lines contains 4 integers, \(HH1, MM1, HH2\) and \(MM2\), (\(0 \le HH1, HH2 \le 23\)) (\(0 \le MM1, MM2 \le 59\)), denoting the start time (\(HH1:MM1\)) and end time (\(HH2:MM2\)). It is guaranteed that start and end time will not span midnight.

Output:
Print the minimum number of cabs required.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
5 votes
Tags:
Greedy AlgorithmsAlgorithmsBasics of Greedy Algorithms
Points:20
20 votes
Tags:
AlgorithmsEasyGreedy AlgorithmsSortingapprovedhiring
Points:20
104 votes
Tags:
EasyGreedy Algorithms