Same Tree
来源:互联网 发布:淘宝做外宣技巧 编辑:程序博客网 时间:2024/06/05 09:51
一、题目要求
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.
二、代码实现
bool 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
- 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
- Linux进程间通信——共享内存
- 金融心理学 摘要
- 坐标系统变换
- java基础之字符、字节的概念及其区别
- L4:二维数组、数组类、数组值复制、冒泡排序、二分查找
- Same Tree
- 初学iOS开发C语言基础
- SSIS数据流性能比较(ADO.NET vs. OLE DB vs. ODBC)
- web.xml 详细介绍
- 解析View中的MeasureSpec
- Linux进程间通信——使用信号量
- Linux进程间通信——使用命名管道
- 2015年ALPC暑期专题练习I (计算几何) D Intersecting Lines
- Minimum Depth of Binary Tree