Identical Binary Tree

Check if two binary trees are identical. Identical means the two binary trees have the same structure and every identical position has the same value.

样例


are identical.

are not identical.

思路:

  1. 按照相同的遍历顺序,比较每一个节点的值,如果发现值不同,则不满足条件。

 

发表评论