class Solution {
public:
bool isSymmetric(TreeNode *root) {
if(root == NULL)
return true;
return check(root -> left,root -> right);
}
bool check(TreeNode * left,TreeNode *right){
if(left == NULL && right == NULL)
return true;
if(left == NULL || right == NULL)
return false;
return (left -> val == right -> val) && check(left -> right,right -> left)
&& check(left -> left,right -> right);
}
};
[LeetCode] Symmetric Tree
最新推荐文章于 2019-05-29 13:59:21 发布