572. Subtree of Another Tree ¶
- Time: $O(mn)$, where $m = |\text{nodes}| \in s$ and $n = |\text{nodes}| \in t$
- Space: $O(h)$, where $h = \text{height(s)}$
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|