100. Same Tree
2016-01-28 16:40
141 查看
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.
Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
public boolean isSameTree(TreeNode p, TreeNode q) { if(p == null && q == null) return true; if(p == null || q == null) return false; if(p.val != q.val) return false; return isSameTree(p.left,q.left) && isSameTree(p.right,q.right); }
相关文章推荐
- Crontab 基本使用范例
- 如何在existing的Site Collection中创建PWA site?
- windows怎么对磁盘进行检查?
- CSS视差滚动效果
- oracle 字段合并
- 打印九九乘法表
- 谁?我眼中的DevOps
- QML中MouseArea元素的介绍
- Centos 使用YUM安装MariaDB
- Hystrix 使用与分析
- Android Studio中的Project和Module是个什么鬼?
- python自动化运维 第1章系统基础信息详解 第一节
- matlab---SPAMS稀疏建模工具箱
- 敏捷,能让人类登上月球吗?
- 正则判断是否是电话号Swift
- 自定义UIPageControl圆点背景图片
- 第二次作业———“A+B Format”思路与总结
- org.apache.log4j.Logger 详解 非常详细
- 三种最典型的大数据存储技术路线
- 网站后台数据存储