could u please tell me where is my code wrong
I wrote the code but answers was wrong
plz do something, iām stuck since last 2 days
Cloud you please provide me the question.
1 Like
@therealsanjeev you are using the wring approach. You are finding the duration of longest activity and then selecting the activities with that duration.
eg
1 2
3 4
5 6
7 100
your max = 93 , ans 1, when you could have easily selected all 4.
To solve this problem, sort the vector of pair according to second.
Then select the activities that can be performed.(you can perform next activity only when current activity end.)
Here is the code you can refer.
If this resolves your doubt mark it as resolved.