Flag Doors Held Open Past an Access Control Threshold

Last updated: November 29, 2026

Quick Overview

Given unordered door sensor events (timestamp, door_id, 'open' or 'close'), return every opening that lasted longer than a threshold, plus any door still open at the end of the log.

Verkada
Coding & Algorithms
Software Engineer
Verkada
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given unordered door sensor events (timestamp, door_id, 'open' or 'close'), return every opening that lasted longer than a threshold, plus any door still open at the end of the log.

Verkada access control raises a door held open alert when a propped door stays open, and the same logic runs on door controllers and in the cloud. The interviewer checks clean state tracking per key and sensible behavior with messy sensor data.

What the Interviewer Expects
  • Sorts events by time before processing
  • Tracks open state per door with a hash map
  • Defines behavior for duplicate opens and closes with no open
  • Reports doors still open at the end of the log
  • Explains O(n log n) time and O(d) extra space for d doors
Key Topics to Cover
hash maps
event processing
state machines
sensor noise
access control
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you raise the alert in real time instead of after the fact?
  • A valid badge scan should extend the allowed open time for that opening. How does the state change?
  • Sensors sometimes bounce open/close/open within 200 ms. How do you debounce?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Each door alternates open and close in an ideal world, but real logs have duplicates and missing events. Rules I will state: a repeated open keeps the first open time, a close without an open is ignor...

High-Level Design

Sort events by timestamp (ties broken by door id so output is deterministic). Keep opened[door] = ts. On close, pop the start and compare the duration to the threshold. After the loop, anything left...


Submit Your Answer
Markdown supported

Related Questions