Twin Trees
Given two binary trees, root0
and root1
, return whether their structure and values are equal.
Constraints
n ≤ 100,000
wheren
is the number of nodes inroot0
m ≤ 100,000
wherem
is the number of nodes inroot1
https://binarysearch.com/problems/Twin-Trees
Examples
Example 1
Input
- root0 =
- root1 =
Output
- answer =
False
Explanation
These two trees are not twins since their values are different.
Example 2
Input
- root0 =
- root1 =
Output
- answer =
True
Explanation
These two trees have the same values and same structure.
Example 3
Input
- root0 =
- root1 =
Output
- answer =
False
Explanation
These two trees are not twins since their structure is different.
Leave a comment