找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 2780|回复: 0

[代码与实例] Lintcode469 Identical Binary Tree solution 题解

15

主题

15

帖子

15

积分

贫民

积分
15
Jenny 发表于 2018-6-16 22:15:11 | 显示全部楼层 |阅读模式
【题目描述】
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.
检查两棵二叉树是否等价。等价的意思是说,首先两棵二叉树必须拥有相同的结构,并且每个对应位置上的节点上的数都相等。

【题目解析】
对两棵树同时使用递归进行前序遍历,并对同一位置的节点进行判断,如有不相等则不是等价二叉树。






回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表