LeetCode100——Same Tree
2015-02-05 15:35
337 查看
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.
容易
Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
难度系数:
容易
实现
[code]bool isSameTree(TreeNode *p, TreeNode *q) { if (p == NULL && q == NULL) return true; else if (p == NULL || q == NULL) { return false; } else if (p->val != q->val) { return false; } return isSameTree(p->left, q->left) && isSameTree(p->right, q->right); }
相关文章推荐
- LeetCode 100: Same Tree
- leetcode 100 Same Tree C++
- Leetcode-100: Same Tree
- leetcode 100 SameTree 3行
- 【一天一道LeetCode】#100. Same Tree(100题大关)
- leetcode100 Same Tree java
- 【一天一道LeetCode】#100. Same Tree(100题大关)
- leetcode_c++:树: Same Tree(100)
- LeetCode Same Tree 100
- LeetCode@Tree_100_Same_Tree
- leetcode 100 —— Same Tree
- <LeetCode OJ> Same Tree【100】
- 【LeetCode】(100)Same Tree(Easy)
- leetcode:100 Same Tree-每日编程第六题
- LeetCode 100:Same Tree
- LeetCode 100:Same Tree
- leetcode100题< Same Tree >(java)
- [LeetCode]: 100: Same Tree
- LeetCode: Same Tree [100]
- leetcode: (100) Same Tree