problem
solution
option 1 - vector record
1 | class Solution { |
option 2 - dfs
1 | class Solution { |
option 3 - bfs
1 | class Solution { |
analysis
- option 1
- time complexity
O(n)
n is number of node - space complexity
O(n)
- time complexity
- option 2
- time complexity
O(n)
- space complexity
O(1)
- time complexity