Java solution


  • 0
    W
    public class Solution {
        public int findMinArrowShots(int[][] points) {
            if (points == null || points.length == 0) return 0;
            Arrays.sort(points, (p1, p2)->p1[0] - p2[0]);
            int res = 1, start = points[0][0], end = points[0][1];
            for (int i = 1; i < points.length; i++) {
                start = points[i][0];
                if (points[i][0] > end) {
                    res++;
                    end = points[i][1];
                } else {
                    end = Math.min(end, points[i][1]);
                }
            }
            return res;
        }
    }

Log in to reply
 

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