Can anyone explain why my code is not working for the first part?

I have tested my code orally acc. to me It should work fine but it is only working for second part not for first part

Hi @Deepanshu_garg, your algo is correct except for 2 things:

  1. Check the conditions in line no. 18. It’s partially incorrect.
  2. Check for boundary conditions. That where should you put an = to sign and where not in the if conditions.

Hope this helps :slight_smile:

I have made some changes in

Can you check whether ithey are right??