Feel free to check out the image source below for the original statement 🦖
Imagine you’re organizing a grand, exclusive event that has everyone buzzing with excitement. The event kicks off at time 0, and guests start arriving at various times, measured in seconds since the event began. To attend, each guest must go through an ID check, which takes a precise 5 minutes (or 300 seconds) to complete. However, there’s a rule that adds a bit of drama: if a guest arrives and finds that there are already more than 10 people waiting in line for their ID check, they decide to leave right away, without going through the process. Your mission is to figure out when each guest will finish their ID check. If a guest leaves because the queue is too long, their completion time will be the same as their arrival time. Here’s how things work: The queue size is determined by how many people are waiting to start their ID check. The person currently being checked isn’t counted in this queue size. If a new guest arrives exactly when another person finishes their ID check, the guest who was waiting in line will be processed first. The new arrival will join the queue, waiting for their turn. Your task is to create a function named solution that takes an array of arrival times as input and returns an array where each entry shows when the guest’s ID check will be completed. If a guest leaves due to a long queue, their completion time should match their arrival time. Get ready to dive into the world of exclusive event management and determine who gets their ID checked and when!
Example 1:
Input: times = [4, 400, 450, 500]
Output: [304, 700, 1000, 1300]
Explanation:Feel free to check out the image source below for the original explanation 🦖 In a bustling hall, the process of ID checks unfolded like a well-choreographed dance: At precisely 4 o’clock, the first guest arrived. With no one else waiting, they were swiftly ushered in to begin their ID check. The queue remained blissfully empty. By 304, the first guest had completed their check and departed, leaving the queue just as serene as before. As the clock struck 400, the second guest arrived. Seeing that the queue was still clear, they too began their ID check right away. The queue stayed empty. When the third guest arrived at 450, there was one person currently being checked. So, they patiently joined the queue, now marked with their name. The fourth guest arrived at 500 and noticed the queue had one person waiting. They added their name to the queue, which now held two. The scene shifted at 700, as the second guest’s ID check concluded. This allowed the third guest, who had been waiting, to step up and start their own ID check. The queue was now down to just one person. By 1000, the third guest finished their check, and the fourth guest took their turn. The queue had emptied once more. Finally, at 1300, the fourth and last guest completed their ID check, bringing the day’s events to a smooth and orderly end.
Example 2:
Input: times = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
Output: [301, 601, 901, 1201, 1501, 1801, 2101, 2401, 2701, 3001, 3601, 13, 14, 15]
Explanation:Feel free to check out the image source below for the original explanation 🦖 At the crack of 1 o’clock, the first guest arrived at the event and seamlessly began their ID check, setting the stage for what was to come. Soon after, a steady stream of 11 additional guests arrived, each one finding their place in the growing queue, eager to complete their own ID checks. However, as the queue stretched to more than 10 people, the last three guests arrived, glanced at the lengthy line, and decided to turn away. Seeing the daunting number of people waiting, they chose to leave, vanishing into the crowd as the others continued to wait their turn.
Unknown for now



input:
output: