Event Time
Reported by candidates from ZipRecruiter's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The ZipRecruiter Event Time question, reported in February 2024, looks like a story problem and plays like a queue simulation. Everything hinges on a queue that tracks who's waiting and when the current person finishes. Arrivals come in sorted order, each check takes 300 seconds, and anyone who shows up to more than 10 waiting people walks out. If you've got this OA coming in a day or two, the logic is short but the edge cases bite. StealthCoder is the safety net running invisibly during the live OA if your head goes blank on the queue bookkeeping.
The problem
Feel free to checkout the image source at the bottom of the page for the original problem statement 🦜 Imagine an exclusive event that everyone is eager to attend. The doors open at time 0, and people begin to arrive, each with their own special time of arrival, counted in seconds since the start of the event. But there's a little twist, before anyone can step inside, they must go through a thorough ID check. This check takes exactly 5 minutes (or 300 seconds) per person. Now, here's where things get tricky: if a person arrives and sees that there are already more than 10 people waiting in line for the ID check, they decide to leave immediately. They simply cannot bear the wait and head home without ever getting their ID checked. Your task is to determine the time each person will finish their ID check, starting from the time they arrived at the event. If someone leaves upon arrival because the queue is too long, their "processed" time will be the same as their arrival time, no ID check for them! Here are a few more things to keep in mind: The queue size is determined by how many people are waiting to begin their ID check. The person currently getting checked doesn't count toward the queue. If multiple people arrive at exactly the same moment and the queue grows, the person who has fewer people ahead of them will be processed first, while the others will patiently wait their turn. Your goal is to return an array of integers where each number represents the exact moment in seconds when a person finishes their ID check, or if they left immediately, it's simply their arrival time. Now, go ahead and figure out who gets into this exclusive event and when their ID checks are complete! Function processAttendees(times: int[]) → int[] Examples Example 1 times = [4, 400, 450, 500] return = [304, 700, 1000, 1300] Feel free to checkout the iamge source below for the original explanation :) In a bustling office, a series of events unfolded as people lined up for their ID checks: At the stroke of 4, the first visitor arrived. Since the office was empty, they were immediately ushered in for their ID check. The queue was a quiet, empty space. By 304, the first visitor had completed their ID check and left, leaving the queue just as serene as before. As the clock struck 400, the second visitor walked in. With no one in sight, they too started their ID check right away. The queue remained empty. When the third visitor arrived at 450, the office was still busy with the second visitor inside. So, they patiently took their place in the queue, now marked by a single name. Shortly after, at 500, the fourth visitor arrived. Noting the presence of one person already waiting, they joined the queue, which now held two names. At 700, the second visitor's ID check was completed, freeing up the office for the third visitor to step up. The queue now had just one name waiting. The clock struck 1000, and with the third visitor's check finished, the fourth visitor began theirs. The queue was now empty, with only the hum of activity left. By 1300, the fourth and final visitor finished their ID check, bringing an end to the day's lineup of visitors. Example 2 times = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] return = [301, 601, 901, 1201, 1501, 1801, 2101, 2401, 2701, 3001, 3301, 3601, 13, 14, 15] Feel free to checkout the iamge source below for the original explanation 🐟 Once upon a time at a grand event, the first guest arrived at the stroke of 1 o'clock and began their ID check right away. Soon after, a wave of 11 more guests arrived, each one joining the queue behind the first guest. The queue grew longer with each new arrival, as they patiently waited their turn. However, as the queue stretched beyond 10 people, the last three guests took one look at the growing line and decided to leave. They felt overwhelmed by the number of people waiting and chose to forgo their ID checks, disappearing into the crowd instead. And so, the event continued with the queue still bustling with anticipation. Constraints Unknown for now
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is to keep a queue of finish times for people who were accepted. For each arrival at time t, pop every finish time that is less than or equal to t, since those people are done. What remains is the set still in the system. The person being checked doesn't count toward the queue, so waiting count is the queue size minus one when someone is mid-check. If waiting is already above 10, record t as that person's answer. Otherwise their start is max(t, last finish time), and their finish is start plus 300. Push it and record it. The classic pitfall is the off-by-one: counting the person being checked as waiting. Example 2 is your test, since the last three leave. Same-time arrivals are handled by processing them in input order. If you blank mid-assessment, StealthCoder can hand you the clean loop.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Event Time cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass ZipRecruiter's OA.
ZipRecruiter reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Event Time FAQ
What data structure does Event Time need?+
A queue, or a deque, holding finish times of accepted people. Pop from the front while the front finish time is at or before the current arrival. The size after popping tells you who's still in the system. A plain list with an index pointer works too.
How do I count the waiting queue correctly?+
The person currently being checked doesn't count. So if the queue of unfinished people holds k entries, waiting is k minus 1 (or 0 if empty). Leave only when waiting is more than 10, meaning k is 12 or more. Example 2 confirms this: 12 get checked, 3 leave.
How do I compute each person's finish time?+
Start time is the later of their arrival and the previous accepted person's finish time. Add 300 seconds. For example 1, the person at 400 starts at 400 because the first finished at 304, so they finish at 700. Leavers just get their arrival time.
How hard is this problem really?+
Easy to medium. There's no fancy algorithm, just a simulation over sorted arrivals. It's O(n) time with a queue. Most failures come from the off-by-one on the queue limit and forgetting to drain finished people before checking the line length.
How do I prepare for this in 48 hours?+
Hand-trace example 2 until the 12 accepted and 3 rejected result feels obvious. Then write the loop once from scratch: drain finished, check waiting, compute start and finish. Test with a gap larger than 300 seconds and with duplicate arrival times.