← AlgoMindset 75

Keys and Rooms

Medium🎙 Interview me on this

🧠 Before you code — what pattern fits?

There are n rooms labeled 0..n-1; all rooms are locked except room 0. rooms[i] is the list of keys found in room i. Return true if you can visit all the rooms.

[[1],[2],[3],[]] → true

[[1,3],[3,0,1],[2],[0]] → false

🎬 Video explanation · Nick White

Your solution runs against 2 unit tests, including edge and large-value cases.

Loading...

Test console · 2 unit tests

Submit your code to run it against all 2 unit tests. Results appear here.

JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.