Same Tree
Approach 1: ⭐⭐
asdasdasd
Note that in the isSameTree() method, we can replace the first two lines of code with if (s == null || t == null) return s == t;
However, this is arguably less readable.
Complexity Analysis
-
Time: \(O(N)\). asd
-
Space: \(O(N)\). asd
Approach 2: asdasdasd Morris Traversal ⭐
Complexity Analysis
-
Time: \(O(N)\). asd
-
Space: \(O(N)\). asd