Symmetric Tree

 

    bool isSymmetric(TreeNode *root) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        if(!root)
            return true;
        return helper(root->left,root->right);
    }
    
    bool helper(TreeNode* root1, TreeNode* root2)
    {
        if(!root1&&!root2)
            return true;
        if(!root1||!root2)
            return false;
        if(root1->val!=root2->val)
            return false;
        return helper(root1->left,root2->right)&&helper(root1->right,root2->left);
    }

  

posted @ 2013-10-05 09:43  summer_zhou  阅读(163)  评论(0编辑  收藏  举报