Answer is right but test case wrong

question= https://hack.codingblocks.com/contests/c/443/1281
solution=https://ide.codingblocks.com/#/s/17072

solution = https://ide.codingblocks.com/#/s/17698
plz help @O17LPOLC0033

Heyy ! , try to do this using recursion because if you are trying with iterative way it may possible that you are missing some corner case .
https://ide.codingblocks.com/#/s/17744