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.
Submissions
Please login to view your submissions
Similar Problems
Points:20
9 votes
Tags:
Basics of Greedy AlgorithmsMathGreedy AlgorithmsAlgorithms
Points:20
238 votes
Tags:
ApprovedEasyGreedy AlgorithmsImplementationOpen
Points:20
20 votes
Tags:
AlgorithmsEasyGreedy AlgorithmsSortingapprovedhiring
Editorial