Skip to content

Commit

Permalink
Time: 75 ms (33.21%), Space: 17.2 MB (27.28%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
hovanhoa committed Oct 18, 2023
1 parent 597ceab commit dc28f1c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 0871-keys-and-rooms/0871-keys-and-rooms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution:
def canVisitAllRooms(self, rooms: List[List[int]]) -> bool:
seen = [False] * len(rooms)

def dfs(node: int) -> None:
seen[node] = True
for child in rooms[node]:
if not seen[child]:
dfs(child)

dfs(0)
return all(seen)

0 comments on commit dc28f1c

Please sign in to comment.