Last to Be Checked π³
Learn this problemProblem statement
An event starts at time 0. Each value in moments is one attendee's arrival time in seconds. One ID check takes exactly 5 minutes (300 seconds), and attendees are processed in arrival order.
When an attendee arrives, count only the people waiting to start their ID check; do not count the person currently being checked. If more than 10 people are already waiting, the new attendee leaves immediately. Otherwise, the attendee joins the queue.
If an attendee arrives exactly when a check finishes, the first person already waiting starts next, and the new attendee joins behind the waiting attendees. Return the time in seconds when the final accepted attendee finishes being processed.
Function
lastToBeChecked(moments: int[]) β intExamples
Example 1
moments = [1, 6, 9, 502]return = 1201The first check runs from second 1 to 301. The remaining accepted attendees are processed in arrival order, so the last check finishes at second 1201.
Constraints
Unknown for now