1 public class Solution { 2 public boolean isSameTree(TreeNode p, TreeNode q) { 3 if(p==null) return q==null; 4 if(q==null) return p==null; 5 if(p.val==q.val){ 6 return isSameTree(p.left,q.left)&&isSameTree(p.right,q.right); 7 } 8 else return false; 9 } 10 }
相关文章
- 12-21Struct_chapter3_Tree
- 12-21秦曾昌人工智能课程---6、Decision Tree Learning
- 12-21source tree图谱和多分支开发
- 12-21LeetCode :: Sum Root to Leaf Numbers [tree、dfs]
- 12-21树-伸展树(Splay Tree)
- 12-21SB Tree(数组)
- 12-21Codechef TSUM2 Sum on Tree 点分治、李超线段树
- 12-21【MOBAN】树上莫队SP10707 COT2 - Count on a tree II
- 12-21「BZOJ2654」tree
- 12-21Leetcode 104. Maximum Depth of Binary Tree(二叉树的最大深度)