CODE ISNT WORKING ALTHOUGH I DID DRY RUN ND ANSWER IS COMING OUT TO BE CORRECT
hey @dhruv.mahajan.mait it seems that you have not understood the input format because you are not taking the input in the corrected format .
first you have to take input for the number of test cases .
Sir im not taking test cases right now. im trying to solve the ques for one case now. nd i think my logic is a bit complicated nd code lenthy too. plz just check the code for by ignoring test cases for now
@dhruv.mahajan.mait
lets discuss from the begining how we can do this question .
there is one vector of pair in which you have to sort according to the ending time .
if the activity is not ended then you can start the new activity .
that’s why first you will sort the array of pair according to ending time .
then you will first take the counter variable and initialise it with1 and start the loop from 1 till less then n .
in that if the starting time of the activity is greater then the ending time then you will increment the counter variable .
then take one more variable to initialise it with that position when condition satisfies .
this is because it will keep the track which was the last activity .
here is the code for your reference .
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.