Xiaohe-LeetCode 100 Same Tree
Best Solution 0ms
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
bool isSameTree(struct TreeNode* p, struct TreeNode* q) {
if (p==NULL&&q==NULL)
return 1;
else if ((!p&&q)||(p&&!q))
return 0;
return (isSameTree(p->left,q->left)&&isSameTree(p->right,q->right))&&(p->val==q->val);
}