Same Tree [LeetCode]
2013-10-18 06:14
351 查看
Problem Description: http://oj.leetcode.com/problems/same-tree/
class Solution { public: bool isSameTree(TreeNode *p, TreeNode *q) { // Note: The Solution object is instantiated only once and is reused by each test case. if(p == NULL && q == NULL) return true; if(p == NULL && q != NULL || (p != NULL && q == NULL)) return false; if(p->val != q->val) return false; return isSameTree(p->left, q->left) && isSameTree(p->right, q->right); } };
相关文章推荐
- Leetcode-100: Same Tree
- LeetCode Same Tree
- 4.5 leetcode -5 same-tree
- LeetCode:Same Tree - 判断两颗树是否相等
- LeetCode Same Tree
- LeetCode:Same Tree && Reverse Integer
- leetcode解题之100# Same Tree Java版
- [leetcode]Same Tree @ Python
- leetCode(14):Invert Binary Tree and Same Tree 分类: leetCode 2015-06-21 11:48 170人阅读 评论(0) 收藏
- LeetCode Same Tree
- LeetCode Same Tree
- leetcode Same Tree
- LeetCode Same Tree
- LeetCode Same Tree (判断相同树)
- LeetCode Same Tree
- Leetcode 100 : same Tree
- LeetCode Same Tree
- leetcode Same Tree python
- LeetCode Same Tree
- leetcode之Same Tree