Problem · Queue
Queue Check-in Simulation with Capacity Limit
Complete the function below. The function receives the full standard input as a single string and must return the exact standard output lines for the described problem.
There is a single check-in line. You are given an integer array arrivalTimes where arrivalTimes[i] is the time (in seconds) when person i arrives at the end of the line.
Rules:
- Only one person is processed at a time. The person at the front of the line takes 30 seconds to check in.
- When a person arrives, if the number of people currently waiting or being served in the system is strictly greater than 10 (i.e., the system already contains more than 10 people), that person leaves immediately and will not check in.
arrivalTimesis non-decreasing; persons arriving at the same time are enqueued in input order.
Return an array result where:
- If person
iis served,result[i]is the time they start service. - If person
ileaves due to capacity,result[i]is represented as the literal stringnullin the output.
Input format: The first line contains an integer n (the number of people). The second line contains n space-separated integers representing arrivalTimes.
Output format: A single line containing the space-separated entries of result, where each entry is either an integer (start service time) or the literal token null (for persons who left due to capacity).
Examples
01 · Example 1
input = "3\n0 0 0" return = 0 30 60
3 people all arrive at time 0. Person 0 starts service immediately at time 0. Person 1 waits and starts at time 30. Person 2 starts at time 60. The system never exceeds capacity, so result = [0, 30, 60].
Constraints
1 <= n <= 2 × 1050 <= arrivalTimes[i] <= 109arrivalTimesis non-decreasing.- A person leaves immediately (result is
null) if, at the moment of their arrival, the number of people already in the system (waiting or currently being served) is strictly greater than 10. - The literal string
null(lowercase) is used in the output to represent a person who left due to capacity.
More Capital One problems
- Compare Counts Around PivotOA · Seen Jun 2026
- Reconstruct Landmark JourneyOA · Seen Jun 2026
- Count House Segments After DestructionOA · Seen May 2026
- Count Numbers with Even Number of DigitsOA · Seen May 2026
- Laser Robot Safe PathOA · Seen May 2026
- Longest Same-Character SubstringOA · Seen May 2026
- Cyclic Shift to Strictly Descending ArrayOA · Seen May 2026
- Dynamic Wall Building and Range QueryOA · Seen May 2026
public String[] solveOneQueueCheckInSimulation(String input) {
// write your code here
}
input"3\n0 0 0"
expected["0 30 60"]
checking account