Optimizing Arrow Shots For Non-Overlapping Balloons
Sort balloons by end point, then iterate to find non-overlapping intervals. Count the number of intervals and return as minimum arrows needed.
Problem class Solution { public int findMinArrowShots(int[][] points) { //remove all the overlapping baloons //this will lead to only baloons that are not overlapping //and we will need at min that many arros to burst them //step1 : sort the give points in ascending order of Xend Arrays.sort(points,(a,b)-> Integer.compare(a[1],b[1])); //step2: get the count of non overlapping intervals and that will the no. of arrows we will need int xstart = points[0][0]; int xend = points[0][1]; int count =1;// atleast one arrow i...