leetcode 100

来源:互联网 发布:战舰世界腓特烈数据 编辑:程序博客网 时间:2024/05/23 19:31

#100 Same Tree

Question:

Given two binary trees, write a function to check if they are equal or not.

Two binary trees are considered equal if they are structurally identical and the nodes have the same value.

Answer:

判断数值是否相同,递归调用方法判断左子树与右子树。因为返回值为boolean,使用一条语句作递归即可。

0 0
原创粉丝点击