Beat 99.14% Java Solution


  • 0
    M

    public class Solution {
    public int findMinArrowShots(int[][] points) {
    if(points == null || points.length == 0 || points[0].length == 0) return 0;

        Arrays.sort(points, new myComparator());
        int count = 1;
        int end = points[0][1];
        for(int i = 1; i < points.length; i++) {
            if(points[i][0] > end) {
                count++;
                end = points[i][1];
            }
        }
        
        return count;
    }
    
    class myComparator implements Comparator<int[]> {
        public int compare(int[] p1, int[] p2) {
            return p1[1] - p2[1];
        }
    }
    

    }


Log in to reply
 

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