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 is needed to burst baloon(s)
for(int i =1;i<points.length;i++){
if(xend < points[i][0]){// xend is less than than the xstart of next baloon hence they are not overlapping
count++;
xend = points[i][1]; //update xend
}
}
return count;
}
}
Ähnliche Beiträge
Auch interessante Nachrichten Minimum No. of arrows to burst balloons
Thematisch verwandte Begriffe: Minimum, arrows, burst, balloons · 6 Treffer
Click, Click… Boom! Automating Protections Testing with Detonate
Cobalt Strike Beacon Extractor
Automating GOAD and Live Malware Labs
How AI Is Changing Patching and What Devs Need to Know About Exposure Management
7 Async Patterns for Running Agents Concurrently in Python
Videos werden geladen ...
Beiträge werden geladen ...
Videos werden geladen ...
Beiträge werden geladen ...
Videos werden geladen ...
Beiträge werden geladen ...
Videos werden geladen ...
Beiträge werden geladen ...
Videos werden geladen ...
SOCIAL SHARE CARD GENERATOR