easy javascript solution


  • 0
    H
    var findMinArrowShots = function(points) {
        if (points.length === 0) return 0;
        points.sort(function(a, b) {
            if (a[0] > b[0]) return 1;
            return -1;
        });
        var count = 1;
        var point = points[0];
        for(var i = 1; i < points.length ; i++) {
            if (points[i][0] > point[1]) {
                count++;
                point = points[i];
                continue;
            }
            if (points[i][0] > point[0]) point[0] = points[i][0];
            if (points[i][1] < point[1]) point[1] = points[i][1];
        }
        return count;
    };
    

Log in to reply
 

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