leetcode-101. 对称二叉树

 

leetcode-101. 对称二叉树

 

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
    bool isSymmetric(TreeNode* root) {
        if(root==NULL)
            return true;
        return helper(root->left,root->right);
        
    }

    bool helper(TreeNode* L, TreeNode* R){
        if(L==NULL&&R==NULL)
            return true;
        else if(L&&R){
            if(L->val==R->val)
                return helper(L->left,R->right)&&helper(L->right,R->left);
            else
                return false;

        }else
            return false;
    }
};

 

上一篇:springboot 发送QQ邮件和附件


下一篇:springboot发送邮件,包含附件、图片