Leetcode_100 Same Tree
2015-07-15 14:03
405 查看
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||q.val!=p.val) return false; return isSameTree(p.left, q.left) &&isSameTree(p.right, q.right); } }
相关文章推荐
- Web应用遇到问题记录
- java.lang.IllegalStateException: cannot resize buffer, 305 bytes have been written (Servlet 2.3, sec
- DATAGRID固定表头【转】
- [蜂鸣器不简单]单片机中蜂鸣器的多种运用(长响,短响,多次响)
- X86 内存布局分析(Memory map)
- 十六进制 及进制间的转换
- HDU-1091-A+B for Input-Output Practice (III)(继续水)
- JSP通用7动作命令
- Linux下Jenkins+git+gradle持续集成环境搭建
- Ubuntu12.04下hadoop-2.7.0编译-配置
- codeforces 558c&558d&558e
- 经常需要对WebView中加载的内容是否完成或者是否加载失败进行判别
- The argument is invalid.
- 如何监控iframe里面页面的点击事件
- 【算法设计与分析基础】背包问题
- leetcode 033 —— Search in Rotated Sorted Array
- QT编程,如何使对话框总是最优化
- SMM系列
- vim的taglist插件的使用和配置
- checkbox的选中与取消