Given two binary trees, write a function to check if they are equal or not.

“Two binary trees are considered equal if they are structurally identical and the nodes have the same value.”

Return 0 / 1 ( 0 for false, 1 for true ) for this problem

Example
Input: 1 1 / \ / \ 2 3 2 3 Output: 1 or True
Solution

It’s a simple traversal problem, We can traverse both the tree and verify if node having equal value or not.

Code

Output

1

We encourage you to write a comment if you have a better solution or having any doubt on the above topic.

Leave a Reply

Your email address will not be published. Required fields are marked *