diff --git "a/\347\256\227\346\263\225/LeetCode/isSameTree.c" "b/\347\256\227\346\263\225/LeetCode/isSameTree.c" new file mode 100644 index 0000000..6fface7 --- /dev/null +++ "b/\347\256\227\346\263\225/LeetCode/isSameTree.c" @@ -0,0 +1,29 @@ +#include +#include +#include + +struct TreeNode{ + int val; + struct TreeNode *left; + struct TreeNode *right; +}; + +int isSameTree(struct TreeNode *p, struct TreeNode *q) +{ + if(p != NULL && q != NULL) + { + if(p->val != p->val) + { + return 0; + } + if(!isSameTree(p->left,q->left)) + return 0; + if(!isSameTree(p->right,p->right)) + return 0; + } + else + return p == q; + + return 1; +} +