Test case 4 :-wrong answer


can someone debug my code?
following points might help in debugging:-

  1. i have used ll for c & r.
  2. used greedy approach(considered ‘=’ sign for overlaping of circles)
  3. ans[k-1].second<v[i].first && ans[k-1].first<v[i].first
    for checking if the cricle is overlapping or not.

any case left?

Hello @Mrinali_Mangal,

There is no need to check for this condition: ans[k-1].first<v[i].first
As if the second of a circle is smaller than the first of another circle, then it’s first is automatically smaller the first of another circle.
Though it is not causing any error, but it is no use to check for this condition.

Now, coming back to your question,
You are missing one case, that if first of one circle is same as the second of another i.e intersecting each other at one point but without any overlap.

Modification:
if(ans[k-1].second<=v[i].first)
{
ans.push_back(v[i]);
k++;
}

Hope, this would help.
Give a like, if you are satisfied.

if i will remove equal sign then first 2 cases wont pass.
when i found 2 cases not getting passed, i searched similar post on this discussion forum and found that ‘=’ has been considered an overlapping case.Therefrore, i removed it but after that, test 4 is getting failed.
kindly check it once again.

Here’s the modified code.

It is passing all the testcases.