My Solution
Solution 1: DFS
The Key Idea for Solving This Coding Question
C++ Code 1
Time Complexity
Space Complexity
- is the height while we traverse the graph described by
rooms
.
- In the worst case, the space complexity is .
C++ Code 2
Time Complexity
Space Complexity
- is the height while we traverse the graph described by
rooms
.
- In the worst case, the space complexity is .
Solution 2: BFS
The Key Idea for Solving This Coding Question
C++ Code
Time Complexity
Space Complexity
Miscellane