We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 3bf2129 + a9b5844 commit 5d57b45Copy full SHA for 5d57b45
solution/0100-0199/0100.Same Tree/Solution.cpp
@@ -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