【leetcode】对称二叉树

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */


bool IsSym(struct TreeNode* a,struct TreeNode* b)
{
    if(!&& !b)
        return true;
    if( (!&& b) || (&& !b) )
        return false;
    return  a->val == b->val && IsSym(a->left, b->right) && IsSym(a->right, b->left);
}

bool isSymmetric(struct TreeNode* root){
    if(!root)
        return true;
    return IsSym(root->left, root->right);
}



posted @ 2020-08-14 11:18  温暖了寂寞  阅读(69)  评论(0编辑  收藏  举报