Easy
Quiz
#100 Same Tree
APPROACH
Given roots p and q of two binary trees, return true if the trees are identical — structurally the same with equal values at every corresponding node.
Example 1:
Input: p = [1,2,3], q = [1,2,3]
Output: true
Example 2:
Input: p = [1,2], q = [1,null,2]
Output: false
Example 3:
Input: p = [1,2,1], q = [1,1,2]
Output: false
1 of 4
1:00
What is the optimal approach for this problem?