LeetCode 100. Same Tree
来源:互联网 发布:厦门广电网络数字电视 编辑:程序博客网 时间:2024/05/22 10:38
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.
Nothing special as long as understand tree structure.
bool isSameTree(TreeNode* p, TreeNode* q) { if(!p && !q) return true; if((!p && q) || (p && !q) || (p->val != q->val)) return false; return isSameTree(p->right, q->right) && isSameTree(p->left, q->left); }
0 0
- [LeetCode]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
- [leetcode] 100.Same Tree
- leetCode 100. Same Tree
- [LeetCode]100. Same Tree
- 100. Same Tree LeetCode
- LeetCode 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
- liunx bash 学习记录1
- Android学习(声明)
- 关于const是否分配空间和常量折叠的问题
- javascript入门
- nyoj 6
- LeetCode 100. Same Tree
- iOS 顶部几个按钮切换界面代码
- leetcode-two Sum
- 快速排序的第二种写法
- nyoj 116 士兵杀敌(二)
- 融合计算知识储备
- H5视频类型,仿吴某某参军!
- OSGI--动态创建服务
- sleep()与yied()区别