class Solution {
public int findMinArrowShots(int[][] points) {
Arrays.sort(points, Comparator.comparingInt(point -> point[0]));
int min = 1;
int left = points[0][0];
int right = points[0][1];
for(int i=1; i<points.length; i++) {
if((left <= points[i][0] && right >= points[i][0]) || (left <= points[i][1] && right >= points[i][1])) {
continue;
} else {
left = points[i][0];
right = points[i][1];
min++;
}
}
return min;
}
}
I am getting wrong answer for a certain testcase on leetcode.
[[3,9],[7,12],[3,8],[6,8],[9,10],[2,9],[0,9],[3,9],[0,6],[2,8]]
Answer is supposed to be 2 but my answer comes out to be 1.
New contributor
Aditya Sharma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.