Skip to content

Commit 5d57b45

Browse files
authored
Merge pull request doocs#308 from Stackingrule/dev
feat:add Solution.cpp for 0100.Same Tree
2 parents 3bf2129 + a9b5844 commit 5d57b45

File tree

1 file changed

+8
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)