Check Identical Trees

BINARY TREE

RECURSION

### Problem

Given the roots of two binary trees `root1`

and `root2`

, check if they are identical. Two binary trees are considered identical if they are structurally identical and the nodes have the same value.

### Examples:

`areTreesIdentical([1,2,3], [1,2,3]) // true`

`areTreesIdentical([1,2,3], [1,2,4]) // false`

### Time Complexity

The time complexity of this algorithm is `O(n)`

where `n`

is the number of nodes in the tree.

Loading...

1

2

3

1

2

3