Time Taken to Cross the Door
A hard-tier problem at 49% community acceptance, tagged with Array, Queue, Simulation. Reported in interviews at IMC and 1 others.
Time Taken to Cross the Door hits differently when you see it live. Google and IMC ask it, and it's deceptive: the naive simulation feels right but bakes in a subtle timing bug that costs you points. The problem looks like a queue problem, it walks like one, talks like one, but the door mechanics are trickier. You model people entering and exiting through a single door in a specific time window, and the order matters. Half of candidates get partial credit because they simulate linearly without catching the asymmetry between entry and exit times. If this lands in your assessment and you freeze on the timing logic, StealthCoder surfaces the working model in seconds, invisible to the proctor.
Companies that ask "Time Taken to Cross the Door"
Time Taken to Cross the Door is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code.
Get StealthCoderThe trap is assuming entry and exit are symmetric or that you can process them in a simple loop. The door can only handle one person at a time, and you need to track two separate queues: those waiting to enter and those waiting to exit. The key insight is that entry happens at specific times, exit happens at specific times, and you must simulate the door state correctly across both. Most candidates miss that the door alternates or has a priority rule, and they return an off-by-one or incorrect final timestamp. The actual trick is recognizing this as a discrete event simulation where you process events in chronological order, not just a linear queue walk. When you get the timing model right, the rest flows. Array and Queue operations support the simulation, but Simulation is the real category here.
Pattern tags
You know the problem.
Make sure you actually pass it.
Time Taken to Cross the Door recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Time Taken to Cross the Door interview FAQ
Is this still asked at Google and IMC?+
Yes. Both companies report it. Acceptance rate is near 50%, which means plenty of people get partial credit or time out. It's not trendy enough to be everywhere, but it's solid in the OA rotation for these firms. Expect to see it if you're interviewing there.
What's the real trick I'm missing?+
You have two separate queues and a door that can only serve one person at a time. The trick is deciding priority or order when both entry and exit are pending, and tracking the exact time each person clears. Most fail because they linearize the problem or don't track door availability correctly across both directions.
How do I know when to use Queue vs Array here?+
Queue works for both groups (those waiting to enter, those waiting to exit) because you process them FIFO. Array works too if you iterate linearly. The simulation itself is the hard part. Pick the structure that makes time tracking and door state easiest to reason about for you.
Will a brute-force simulation pass?+
Depends on constraints, but probably yes with some optimization. If you iterate through every second or every event in order, track door state, and correctly assign timestamps, you'll likely get full credit. The gotcha is not off-by-one errors on the final time or missing an edge case in priority logic.
Is this harder than it looks on first read?+
Yes. On first read it feels like a straightforward queue problem. Once you code it, you realize the door mechanics and timing are subtle. The 50% acceptance rate reflects this gap between "I think I understand" and "my solution actually works."
Want the actual problem statement? View "Time Taken to Cross the Door" on LeetCode →