We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 97389ff commit 8599dd5Copy full SHA for 8599dd5
Same Tree.cpp
@@ -0,0 +1,19 @@
1
+/**
2
+ * Definition for a binary tree node.
3
+ * struct TreeNode {
4
+ * int val;
5
+ * TreeNode *left;
6
+ * TreeNode *right;
7
+ * TreeNode(int x) : val(x), left(NULL), right(NULL) {}
8
+ * };
9
+ */
10
+class Solution {
11
+public:
12
+ bool isSameTree(TreeNode* p, TreeNode* q) {
13
+ if(p==NULL && q==NULL)
14
+ return true;
15
+ if(p==NULL || q==NULL)
16
+ return false;
17
+ return ((p->val == q->val)&&(isSameTree(p->left,q->left) && isSameTree(p->right,q->right)));
18
+ }
19
+};
0 commit comments