Java maybe there is a kindof difference solution


  • 0
    T
    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 count = 1, end = points[0][1];
            for(int i = 1; i < points.length; i++)
            {
                if(end < points[i][0])
                {
                    end = (int)Math.max(end, points[i][1]);
                    count++;
                }
            }
            return count;
        }
    }

Log in to reply
 

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