Activity selection problem

It’s showing correct output for sample test cases but fails after submitting. Why?? https://ide.codingblocks.com/s/328464

Hey @div_yanshu07
Your logic is incoorect will fail for a simple test case like this:
1
3
1 2
2 3
1 4
Its output should be 2 but urs giving 3.

Correct approach is this:
A basic activity selection problem which uses Greedy approach. The implementation mentioned here states to sort the activities in the increasing order of their finishing times. Initially, we choose the first activity. Now, starting from second activity, current activity can be selected if the finish time of previous selected activity is less than or equal to the starting time of current activity

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.