ex:
4
1 7
5 8
7 8
1 8
the answer should be 2…but the output i got by this code is 1
This is not pas all test cases
Hi, it depends on the question.
In case, it is asked that the starting time of the next activity should be strictly greater than the ending time of previous activity then the answer will be 1.
Otherwise, if it is allowed to have starting time equal to the ending time of previous activity then the answer is 2.
but this code is not valid for answer 2
Yeah there will be different code for answer = 2 and different code for answer = 1.
The code given is for answer = 1.
Yes, this is correct.
Now if you remove the ‘=’ in line 11, it becomes the code for ans = 1 case.
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.