Imagine an exclusive event that many people wish to attend. The event starts at time 0. For every person attending, you are given a time in seconds (since the start time of the event) representing when they arrived at the event. However, entry into this event requires an identification check which takes time, so people may wait in the queue to enter. Specifically, it takes 5 minutes to do an ID check for every attendee. Additionally, if the person arrives at the event and sees that there are more than 10 people in the queue, they leave immediately.
Your task is to return an array of integers representing the time when each person will be processed and their ID check completed. The time should be in seconds since the start time of the event. If a person leaves immediately upon arrival, this time should be the same as their arrival time.
Notes:
- The queue size is calculated by the number of people waiting to start their ID check, not including the person who is already in the process of ID check.
- If a new person arrives at the same moment as when another person completes their ID check, the first person waiting in the queue should have their ID checked first, and the new person should wait in the queue.
Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(times.length^2) will fit within the execution time limit.
times = [4, 400, 450, 500] return = [304, 700, 1000, 1300]
Let consider this scenario:
- The first person arrives at time
4, and there is no one in the queue, so they immediately start their ID check. Queue =[]. - The first person finishes their ID check at time
304. Queue =[]. - The second person arrives at time
400, and there is no one in the queue, so they immediately start their ID check.
- Count Cyclic Digit PairsOA · Seen Jun 2026
- Count Skipped Numbers After SubtractionsOA · Seen Jun 2026
- Check Even-Position MonotonicityOA · Seen Jun 2026
- Count Alternating Tile GroupsOA · Seen Jun 2026
- Count Even-Digit NumbersOA · Seen Jun 2026
- Inventory Discount TrackerOA · Seen Jun 2026
- Construct WDL StringOA · Seen Jun 2026
- Find Sum PairsOA · Seen Jun 2026
public int[] solution(int[] times) {
// write your code here
}