easy java greedy solution


  • 0
    F
        public int findMinArrowShots(int[][] points) {
            if (points == null || points.length == 0) {
                return 0;
            }
            Arrays.sort(points, (o1, o2) -> Integer.compare(o1[1], o2[1]));
            int result = 1;
            int end = points[0][1];
            for (int i = 1; i < points.length; i++) {
                if (points[i][0] > end) {
                    result++;
                    end = 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.