Code showing wrong output

https://ide.codingblocks.com/s/591340 my code is not working correctly

https://ide.codingblocks.com/s/591343 i have corrected ur code…its working fine now

can you please explain why it will not work if i take it from start rather than end ?

basically this problem is similar to activity selection problem where u have to choose as many as possible

ooh got the logic . thanks

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.