NeetCode #174LC-2534HardArrays & Hashing
← Back to All Problems

#174 · #2534 · Time Taken to Cross the Door(通过门的时间)

📌 Problem Statement & Constraints

There are n people who want to cross a door. arrival[i] is the arrival time and state[i] is 0 for entering, 1 for exiting. Each person takes 1 second to cross, one at a time. Priority rule: if people are waiting on both sides, the side that used the door most recently goes next (exiting has priority if nobody has used the door yet). Return the time each person crosses. Constraints: 1 <= n <= 10^5; arrival is non-decreasing.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!