My easy to understand solution, beat 88%


  • 0
    H
    public class Solution {
        public int findMinArrowShots(int[][] points) {
            if(points.length == 0) return 0;
            Arrays.sort(points, new Comparator<int[]>(){
                public int compare(int[] a, int[] b){
                    return a[1] - b[1];
                }
            });
            
            int ans = 1, arrow = points[0][1];
            for(int i = 1; i < points.length; i ++){
                if(points[i][0] > arrow){
                    arrow = points[i][1];
                    ans ++;
                }
            }
            return ans;
        }
    }
    

Log in to reply
 

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