ON hackerblock it shows wrong ans but on cb ide it shows right. Hackerblock link https://hack.codingblocks.com/app/contests/987/p/59
Code https://ide.codingblocks.com/s/154389
@harshkumar.877587 Hey Harsh, I have pointed out some mistakes and commented there in the code. Please try to resubmit the code and check whether it passes all the test cases.
Hope this helps