Thanks Ayushi! You are doing great job. Just one feedback - Before going into the actual solution please try to provide a dry run on any test case so that the question will be more clear to us.
I feel u solve the imp and problems whose chances of coming in interviews is mots! do u have any list of problems concatinated somehwere so that i solve those? like over some doc?
Hi Darshan, keep looking for openings and if opening is there, then check if the job requirements matches your resume. In some startups, they ask DSA and in some they ask related to development or whatever skill they are looking for, so you need to prepare accordingly :)
Maam I have tried writing down the solution in java : class Solution { public int findMinArrowShots(int[][] points) { Arrays.sort(points,(a,b)-> a[1]- b[1]); int end=points[0][1]; int arrows=1; for(int i=1;iend) { ++arrows; end =points[i][1]; } } return arrows; } } but just 1 test case is not getting executed : points = [[-2147483646,-2147483645],[2147483646,2147483647]] Output : 1 Expected : 2 Please help me out in rectifying the issue in my code ma'am.
class Solution { public int findMinArrowShots(int[][] points) { Arrays.sort(points,(a,b)->a[1]-b[1]); int arrows=1; int end=points[0][1]; for(int i=1;iend){ end= points[i][1]; arrows++; } } return arrows; } } but dont know why it fails in 1 case [[-2147483646,-2147483645],[2147483646,2147483647]] this one
int findMinArrowShots(vector& points) { int ans=1; sort(points.begin(), points.end()); int xend=points[0][1]; for(int i=1; i points[i][1])?points[i][1]:xend; } } return ans; }
Nice xplanation sis However if you are workin on java... * [[-2147483646,-2147483645],[2147483646,2147483647]] this testcase might fail if you use Arrays.sort(intervals, (a, b) -> a[0] - b[0]); to sort the array... Now I did a quick analysis on why it doesn't work? You would understand it clearly if you clearly understand the working mechanism of compare(a-b) #Analysis if(a-b) is > 0 means, b comes before a else if (a-b) b)||(a