Recursive Javascript solution


  • 1
    R
    var isSymmetric = function(root) {
        
        if(!root)
            return true;
        
        var check = function(left, right){
            if(left === null && right === null)
                return true;
            if(left === null || right === null)
                return false;
            if(left.val === right.val)
                return true && check(left.left, right.right) && check(right.left, left.right);
            return false;
        };
        
        return check(root.left, root.right);
    
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.