Same Tree
来源:互联网 发布:linux mv 创建文件夹 编辑:程序博客网 时间:2024/05/29 05:52
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.
public class Solution { public boolean isSameTree(TreeNode p, TreeNode q) { if(p==null&&q==null) return true; else if(p==null||q==null) return false; return p.val==q.val&&isSameTree(p.left,q.left)&&isSameTree(p.right,q.right); }}
0 0
- Same Tree
- Same Tree
- Same Tree
- Same Tree
- Same Tree
- Same Tree
- Same Tree
- Same Tree
- Same Tree
- Same Tree
- Same tree
- Same Tree
- Same Tree
- Same Tree
- Same Tree
- Same Tree
- Same Tree
- Same Tree
- 关于html 界面中元素隐藏的几种方法
- 判断js是否被禁用
- C++中friend的使用(friend function and friend class)
- ie9 scrollbar中hover 高度增高的bug
- 南邮 OJ 1095 奇特的图形
- Same Tree
- C++实现两个字符串之间的Levenshtein Distance(编辑距离)
- 0-1排序引理
- Struts2组合spring
- 常用做action recognition 的数据集介绍
- linux 下编译安装Qt
- 埃博拉病毒的实验室症断
- 无线调试——不需要root也能wifi调式
- HDU 3879 Base Station(最小割的最大权闭包 最大获利)经典