100. Same Tree
2016-03-14 13:07
369 查看
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: bool isSameTree(TreeNode* p, TreeNode* q) { if(p==NULL&&q==NULL) return true; else if(p==NULL||q==NULL) return false; if(isSameTree(p->left,q->left)&&isSameTree(p->right,q->right)&&p->val==q->val) return true; return false; } };
相关文章推荐
- 94. Binary Tree Inorder Traversal
- 线程编程时,需要注意的
- PHP 数组
- 网络设备文件管理
- 复利计算器2.01
- 88. Merge Sorted Array
- 70. Climbing Stairs
- 67. Add Binary
- 66. Plus One
- Spring中LocalSessionFactoryBean与SessionFactory
- ajax请求Url加参数的使用方法
- ViurtualBox配置虚拟机Linux的网络环境
- Visual Stuido 2015 Community 使用 GitHub 插件
- 不小心打开了show children怎么关闭的问题
- Eclipse护眼背景色
- 58. Length of Last Word
- 38. Count and Say
- 27. Remove Element
- 26. Remove Duplicates from Sorted Array
- Linux下简单线程池的实现