JavaScript BFS Recursive Solution


  • 0
    var isSymmetric = function(root) {
        if(!root) return true;
        function mirror(a, b){
            if(!a && !b) return true;
            if(!a || !b || a.val !== b.val) return false;
            return mirror(a.left, b.right) && mirror(a.right, b.left);
        }
        return mirror(root.left, root.right);
    };

Log in to reply
 

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