Same Tree
Given the roots of two binary trees p and q, write a function to check if they are the same or not.

30:00

Same Tree
easy
Topics
Companies

Given the roots of two binary trees p and q, write a function to check if they are the same or not.

Example 1:
Input: {"p":[1,2,3],"q":[1,2,3]}
Output: true
Constraints:
  • The number of nodes in each tree is in the range [0,100][0, 100].

  • 104Node.val104-10^4 \leq \text{Node.val} \leq 10^4

Input
arr ={"p":[1,2,3],"q":[1,2,3]}

1

2

3

1

2

3

Variables
No variables to display
DepthFunction Call
Stack empty
0/12