An airport has podCount private rest pods numbered from 0 to podCount - 1. Travelers reserve these pods for specific time periods while waiting for their flights.
Each reservation is written as "start,end" and represents the half-open time period [start, end). Its duration is end - start. Every reservation has a different start time.
Assign every reservation to a pod using the rules below. Return the number of the pod used for the most reservations.
AirportRestPodPlanner
int findMostUsedPod(int podCount, List<String> reservations)
podCount: The number of available rest pods.reservations: The requested reservation periods. Each string uses the format "start,end".Return the number of the pod used for the most reservations. If multiple pods are used the same highest number of times, return the smallest pod number.
1 ≤ podCount ≤ 1001 ≤ reservations.size() ≤ 100,000reservations contains exactly two integers in the format "start,end".0 ≤ start < end ≤ 500,000start value. findMostUsedPod( podCount = 2, reservations = List.of( "2,9", "3,6", "4,8", "7,10", "8,11"))
Output: 1
The first two reservations use pods 0 and 1. The remaining reservations are delayed when necessary. Pod 0 is used twice and pod 1 is used three times, so the result is 1.
findMostUsedPod( podCount = 3, reservations = List.of( "3,7", "0,20", "6,8", "2,6", "5,6", "1,4"))
Output: 2
The reservations are processed by their start times even though the input is unordered. Pods 0, 1, and 2 are used one, two, and three times respectively.
findMostUsedPod( podCount = 2, reservations = List.of( "1,4", "2,5", "6,9", "7,10"))
Output: 0
Both pods are used twice. Pod 0 is returned because it has the smaller number.