Check Whether a Robot Can Unlock Every Warehouse Room Using Found Badges
Last updated: November 29, 2026
Quick Overview
A warehouse robot starts in room 0, the only unlocked room. Each room contains badges that unlock other rooms. Given the badge list for every room, return True if the robot can eventually enter every room.
Amazon
November 29, 20260
0
0 solved
A warehouse robot starts in room 0, the only unlocked room. Each room contains badges that unlock other rooms. Given the badge list for every room, return True if the robot can eventually enter every room.
An Amazon phone-screen graph warm-up themed on Amazon Robotics floor access. The interviewer checks that you model rooms as nodes and badges as directed edges, then run a plain BFS or DFS reachability check with a visited set.
What the Interviewer Expects
- Model rooms as nodes and badges as directed edges
- Run BFS or DFS from room 0
- Use a visited set so cycles do not loop forever
- Compare the visited count with the number of rooms
- State O(V + E) complexity
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
- Return the list of rooms that can never be reached.
- What if some badges only work once?
- What is the minimum number of extra badges needed so every room is reachable?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: rooms, a list where rooms[i] lists the room numbers whose badges are in room i. Room 0 starts unlocked. Output: True if all rooms can be visited....
High-Level Design
Rooms form a directed graph: an edge i -> j means a badge for j sits in room i. The robot can enter exactly the rooms reachable from 0, so do an iterative DFS with a stack and a visited set. At the ...