Skip to content

Commit eaf129e

Browse files
authored
100 Same Tree
100 Same Tree
1 parent 83204ed commit eaf129e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

isSameTree.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution {
2+
public:
3+
bool isSameTree(TreeNode* p, TreeNode* q) {
4+
if (p==NULL && q==NULL) return true;
5+
if ((p == NULL && q!=NULL) ||(q == NULL && p!=NULL)) return false;
6+
return (p->val == q->val) && isSameTree(p->left, q->left) && isSameTree(p->right, q->right);
7+
}
8+
};
9+

0 commit comments

Comments
 (0)