No test Case working!, Please tell the mistake

Please mention the mistake in the approach

hi @babayaga first you need to sort the activities according to their ending time, then you can greedily choose activities.

1 Like

Okay, can you tell me how to sort this in array of pairs?
Can we implement sort function for pairs?

@babayaga pass the array of pairs in the sort function along with compare function, in the compare function, assuming that pair.second is ending time

bool compare(pair<int, int> p1, pair<int, int> p2) {
    return p1.second < p2.second;
}
1 Like

Thank you so much for the assistance @Ishitagambhir
Really helped me a lot
Marking it as resolved