Shortest Guard Patrol Route Through Active Door Alarms
Last updated: November 29, 2026
Quick Overview
A building is a weighted graph of hallways and doors. Starting from the security desk, find the minimum walking time to visit every door that currently has an active alarm (up to about 15 alarms), in any order, without needing to return.
Verkada
November 29, 20260
0
0 solved
A building is a weighted graph of hallways and doors. Starting from the security desk, find the minimum walking time to visit every door that currently has an active alarm (up to about 15 alarms), in any order, without needing to return.
Verkada Command shows alarms from doors, sensors and cameras on a floor plan, and a dispatch feature that suggests a response route is a natural extension. This onsite problem checks whether you see that it reduces to shortest paths plus a small traveling-salesman DP, and whether you can implement bitmask DP without bugs.
What the Interviewer Expects
- Recognizes the problem as TSP on a small set of target nodes
- Runs Dijkstra from the start and each alarm to build a pairwise distance matrix
- Implements the bitmask DP dp[mask][last] correctly
- Handles unreachable alarms and zero alarms
- States O(k * E log V + 2^k * k^2) and why k must stay small
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- The guard must return to the desk. What changes?
- With 40 alarms the DP is too slow. What heuristic would you ship and how would you bound its quality?
- Some doors are locked and the guard's badge opens only some of them. How do you model that?
- Alarms keep arriving while the guard walks. How would you re-plan?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Graph: adjacency lists with non-negative walk times in seconds, undirected. Inputs: start node and a list of k alarm nodes, k up to about 15. Output: minimum total time, or None if some alarm ca...
High-Level Design
Only the k+1 special nodes matter for ordering. Step 1: Dijkstra from each special node gives a (k+1) x (k+1) distance matrix. Step 2: dp[mask][i] = minimum time to have visited exactly the alarms i...