CodeOath
← All problems

Same Tree

Easy
trees

Given the roots of two binary trees p and q, return true if they are structurally identical and their nodes have the same values.

Trees in this problem are given as level-order arrays: null marks a missing child, and trailing nulls are omitted.

Example:

Input: p = [1,2,3], q = [1,2,3]
Output: true