only one test case working,others not,why?
Maximum circles
@Vibhuti0206 You have sorted the coordinates of the circle according to its starting position.( The default sort function sorts according to the first element of the pair)
You need to sort it according to the ending position such that more space is left for the remaining circles.( just as in activity selection problems)
After that check for the overlapping conditions : ie. if starting point of next circle < ending point of previous circle then increment the count.
what to do after modifying still not working
@Vibhuti0206 Error is due to line number 3.
Change it to bool cmp(pair<int,int> &a,pair<int,int> &b)
Even after that dry and check line 26 onwards…your code is not giving correct output.
It should be something like this:
for(int i=1;i<n;i++)
{
if(v[i].first<v[i-1].second)
count++;
}
cout<<count;
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.