My code runs for one test case out of two test cases

please check where my code is going wrong and correct it

Hi Arya,
in line 13 and 18 just make it <= instead of <
ur code will work fine… corrected code https://ide.codingblocks.com/s/617818

okay now the code is working! but why did we use those two if statements? can you please explain

hi… its a bit difficult to explain like this… try to dry run 2-3 examples u would get the logic…

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.