Unable to pass 2 test cases

This is the link to my code.
Although my approach is the same to that of the hint video but my implementation is a bit different.
Could you help me figure out what I am doing wrong in this code

@sankalp.sharma99
You logic is correct. But your ans might not get stored in int variable. So use long long int and change INF to 10^18. Your code will work.

1 Like

@sankalp.sharma99
Here is the updated code https://ide.codingblocks.com/s/264331

1 Like