Activity selection

Please can someone point the mistake in this code.

This implementation passes the custom test cases but fails when submitted.

You need to compare with the end time rather than the start time. In the comparator just write

bool comp(pair<int,int> p1, pair<int,int> p2){
    return p1.second<=p2.second;
}

Hi u were doing one thing wrong. when u were sorting then u should sort in such a way that activity with the least ending time comes before.
I have made changes to ur code.

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.