Same Tree

Easy · Trees · about 10 minutes

Asked at Amazon, Google, Meta, Microsoft, Bloomberg, Two Sigma.

Given the roots p and q of two binary trees, return true if they are identical: the same shape with the same value at every node.

Related guides