Hey guys. I have wrote a code for the snug_fit challenge but it shows wrong answer. My example test input gave the correct answer. But i think it doesnt cover all the situations. Can anyone point out the error in the logic?
Just change sum to long long int
Ohhh… That worked. Thank you so much for ur help. Realized that something as stupid as that can make or break a whole program.
If you want to check whether your code is overflowing, you can use
#pragma GCC optimize "trapv"
At the top of the code.
It will give a runtime error instead of Wrong answer.
What does that do? I know just the basics of CPP coding.
It gives Runtime error if something overflows, instead of wrong answer.
Ohh… Got it