Return whether two binary trees have identical structure and equal values at corresponding nodes.
Example 1
Argument 1 tree: level-order input; omitted children are null.Argument 2 tree: level-order input; omitted children are null.p = [1,2,3]
q = [1,2,3]
true
Explanation
Corresponding values and left/right arrangements match throughout.
Example 2
Argument 1 tree: level-order input; omitted children are null.Argument 2 tree: level-order input; omitted children are null.p = [1,2]
q = [1,null,2]
false
Explanation
2 is a left child in one tree and a right child in the other, so shapes differ.
Example 3
Argument 1 tree: empty tree (null root).Argument 2 tree: empty tree (null root).Explanation
Two empty trees match structurally.
Constraints
- 0 <= nodes per tree <= 10000
- Trees are breadth-first arrays with null holes
Function contractisSameTreeArguments: tree, tree