Problem · Array

Event ID Check Completion Times

Learn this problem
MediumRoblox logoRobloxINTERNOA
See Roblox hiring insights

Problem statement

An exclusive event starts at time 0. People arrive over time, and one identification-check station processes them before entry. Every ID check takes exactly 300 seconds (5 minutes).

Given a nondecreasing integer array times, where times[i] is the arrival time in seconds of person i, return an integer array containing one result for each person in input order:

  • If the person joins the line, return the time when their ID check finishes.
  • If the person leaves immediately, return their arrival time.

Process arrivals chronologically. People with the same arrival time are considered in input order. The queue follows these rules:

  • The queue size counts only people waiting to start their ID check. It does not include the person currently being checked.
  • A person leaves only when they arrive and see more than 10 people waiting. A person who sees exactly 10 people waiting joins the queue.
  • If an arrival occurs at the same time as a check finishes, apply that completion first. A person who was already waiting starts before the new arrival is considered, so the newcomer waits behind the existing queue.
  • A person who leaves does not occupy the station or the queue.

A solution with time complexity no worse than O(times.length^2) fits within the execution limit.

Function

solution(times: int[]) → int[]

Examples

Example 1

times = [4,400,450,500]return = [304,700,1000,1300]

The person arriving at 4 starts immediately and finishes at 304. The person arriving at 400 also finds an idle station and finishes at 700. The arrivals at 450 and 500 wait in that order, so their checks finish at 1000 and 1300.

Example 2

times = [0,100,300]return = [300,600,900]

The first check finishes at 300. At that same time, the person who arrived at 100 was already waiting and starts next, finishing at 600. The new arrival at 300 waits behind them and finishes at 900.

Constraints

  • 1 ≤ times.length ≤ 1000
  • 0 ≤ times[i] ≤ 10^9
  • times[i] ≤ times[i + 1] for every valid i

More Roblox problems

drafts saved locally
public int[] solution(int[] times) {
  // Write your code here
}
times[4,400,450,500]
expected[304,700,1000,1300]
checking account