100. Same Tree
来源:互联网 发布:手机遥控玩具车软件 编辑:程序博客网 时间:2024/06/18 14:46
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.
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { 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); }}
阅读全文
0 0
- [LeetCode]100.Same Tree
- LeetCode 100. Same Tree
- 100.Same Tree
- 【LeetCode】100.Same Tree
- [Leetcode] 100. Same Tree
- [Leetcode] 100. Same Tree
- LeetCode --- 100. Same Tree
- LeetCode 100. Same Tree
- [leetcode] 100.Same Tree
- 100.Same Tree
- 100. Same Tree
- 100.Same Tree
- 100. Same Tree
- 100. Same Tree
- 100. Same Tree
- leetCode 100. Same Tree
- 100. Same Tree
- [LeetCode]100. Same Tree
- 学习网址
- JAVA重新学习第一篇-java是什么
- 通过示例看JavaScript的闭包
- java se TCP上传文件
- 贪心算法(上)
- 100. Same Tree
- Angular中ng-repeat与ul li的多层嵌套
- 在centos7上搭建hadoop集群
- RecyclerView使用——入门篇
- AtCoder Grand Contest 018 A
- 亚信实习第二周(7.17-7.23)
- java多线程一(基础篇)
- CNN(卷积神经网络)、RNN(循环神经网络)、DNN(深度神经网络)的内部网络结构有什么区别?
- #bzoj3037#无线电通信(DP)