The following code for piyush and magical park is failing few test cases.
Please check my code and let me know why it’s working fine for few test cases and not for others though logic is correct.
The following code for piyush and magical park is failing few test cases.
Please check my code and let me know why it’s working fine for few test cases and not for others though logic is correct.
Hello @mahima when you have find that your strength is less than k at anypoint then you have to break you should not return in that case because if you will return then your code will not print ‘no’ for that answer.Infact there will be no ouput for that answer becaus you have then returned to the main from where you have called this fucntion.
whereas if you will break it will break the loop only and then afterwards it will check for the if condition.
this is the error.
just replace the return with break and your code will pass all the test cases:
Happy Learning!!
so if I will do cout<<“No”; and then return
will it work?
okay thanks for the help
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.