Clean JS code beats 92%


  • 0
    M
    /**
     * @param {number[][]} points
     * @return {number}
     */
    var findMinArrowShots = function(points) {
        let result = 0,
            len = points.length,
            max = -Number.MAX_VALUE;
            
        points.sort((a, b) => a[0]-b[0] || a[1]-b[1]);
        
        for (let i = 0; i < len; i++) {
            if (points[i][0] > max) {
                result++;
                max = points[i][1];
            }
            max = Math.min(max, points[i][1]);
        }
        
        return result;
    };

Log in to reply
 

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