problem
solution
option 1 - backtracking
1 | class Solution { |
option 2 - bfs
1 | class Solution { |
analysis
- option 1
- time complexity
O(n)
n is node - space complexity
O(h)
h is height or depth
- time complexity
- option 2
- time complexity
O(n)
n is node - space complexity
O(n)
n is node
- time complexity