Problem Submissions Solution

Same Binary Tree

Difficulty: Easy

Acceptance: %

Points: 20.00

Two binary trees are considered the same if they are identical in structure and the nodes have the same value.

Give the root of two binary trees, check if they are the same or not.

Return 1 if they are same, else return 0.

Topics

Companies

Articles

Examples:

Expected Time Complexity: O(n)

Expected Auxiliary Space: O(log n) for recursive calls.

Constraints:
  • 1 <= number of nodes <= 10^5
  • 1 <= node->data <= 10^9
Companies:
Amazon Microsoft Flipkart
Topics:
Tree
Locked Content
Access Restricted: Please Login to access the code editor and test cases.