Pier Ticket Window Time
Before the lantern parade, guests queue at ticket windows placed along the pier. Each window processes one guest at a time at a fixed rate, and all windows work in parallel. The festival director wants to know how soon the entire queue can be cleared so performers can lead visitors to the seating tiers. Choosing an earlier parade time makes the lighting choreography tighter, so the director needs the minimum time in minutes that finishes everyone given the available windows.
You receive the processing rates as an array where each value is the number of minutes a specific window needs to serve one guest, plus the total number of guests waiting. Determine the smallest integer time such that the windows combined can serve at least that many guests within the time limit. Use binary search over time, computing how many guests each window can handle in the candidate duration, and avoid modifying the input. This lets the director confirm staging cues, coordinate snacks, and keep the pier walkway flowing.
Example 1:
Input: rates = [2,3], guests = 6
Output: 8
Explanation: In 8 minutes, window 1 serves 4 guests and window 2 serves 2 guests.
Example 2:
Input: rates = [5,7,10], guests = 8
Output: 20
Explanation: After 20 minutes the windows collectively handle eight guests.
Example 3:
Input: rates = [4], guests = 0
Output: 0
Explanation: With no guests, zero minutes are required.
Algorithm Flow

Best Answers
Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this problem.
