Challenge: Identical Trees

Let’s check if two binary trees are equal.

Problem

Find out if two binary trees have identical values.

Input

Two binary trees.

Output

Returns true if the given trees are identical. Otherwise, it returns false.

Sample input

The root nodes t.root and t2.root of two binary trees will be our input. We have to find if the trees are identical using the isEqual() function.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.