PIXELBANKv8.2.1
Menu

Same Tree

Given two binary trees (level-order arrays), check if they are structurally identical with the same node values.

Example:

Input:
1,2,3
1,2,3
Output:
True
Reasoning:
  • The two input arrays 1,2,3 and 1,2,3 represent two binary trees in level-order traversal.
  • We compare the two arrays node by node: both have the same root node value 1, the same left child node value 2, and the same right child node value 3.
  • Since the arrays have the same length and all corresponding node values match, we conclude that the two binary trees are structurally identical with the same node values.
  • The function returns True, indicating that the two input trees are the same.

Constraints:

  • 0 <= number of nodes <= 100
Editor

Test Results

0/0
Run code to see test results.