2
def canVisitAllRooms(self, rooms: List[List[int]]) -> bool:3
# Create a set of for rooms visited6
# Create a queue to do a breadth first search visiting rooms7
# Append the first room, 0, to the queue to begin the search8
queue = collections.deque()11
# Perform the breadth first search with the queue13
for _ in range(0, len(queue)):15
room_number = queue.popleft()17
# If we haven't visited the room, get the keys from the room18
if room_number not in visited_rooms:20
# Collect the keys from the room21
found_keys = rooms[room_number]23
# Add the keys to the queue so they can be tested24
for key in found_keys:27
# Add the current room to the visited set28
visited_rooms.add(room_number)30
# If we visited all of the rooms, then the number of visited rooms should be31
# equal to the number of total rooms32
if len(visited_rooms) == len(rooms):