class Solution {
public:
bool isSameTree(TreeNode *p, TreeNode *q) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(!p&&!q) return true;
if(!p&&q||p&&!q||p->val!=q->val) return false;
bool left=isSameTree(p->left,q->left);
bool right=isSameTree(p->right,q->right);
return left&&right;
}
};
Same Tree
最新推荐文章于 2018-10-22 14:17:12 发布