i am not able to get correct strength
code link:https://ide.codingblocks.com/s/99552
No correct answer
Also while moving in a row, Piyush requires strength of 1 for every step and strength should always be positive for moving forward.
You have not taken care of these conditions in your code. And also, you have to print ‘No’ if he cannot escape the park, you haven’t done that also.
you need to read the question again carefully. you didn’t took care for following conditions:
1.His strength should always be greater than K while traversing or else Piyush will get lost
2.He need 1 strength for 1 step, so at each next step his strength will be reduced by 1
3.you need to take care of situation when he can’t escape.
and try to dry run your algorithm for the sample test case.
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.