Can you let me know am i missing any condition because my output isn’t coming right.Here is the code https://ide.codingblocks.com/s/171606
Piyush and magical park
Hey @yath17 some conditions that you didn’t include are,
- if piyush is on the last element of the row you dont need to subtract energy taken for the step
- at every step you have to check if energy is greater than k or not
- you only need to print s when he is able to escape.
Here is code with additional conditions: https://ide.codingblocks.com/s/171611
Let me know if you face any problem.