Skip to content

Commit 99aadbb

Browse files
committed
Same Tree solution
1 parent d18d1f0 commit 99aadbb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

same-tree/PDKhan.cpp

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

0 commit comments

Comments
 (0)