Ctrl K
Problem

Identical Trees

Easy · Identical Trees

You are given the roots of two binary trees, `first` and `second`. Check whether they are the same tree. Two trees are the same when they have the same shape (matching nodes have children on exactly the same sides) and matching nodes hold equal values. Two empty trees count as the same. Return `True` if the trees are identical, and `False` otherwise.…

Solve the problem →