I submitted my answer and only one test case(#5) is giving wrong answer
Can someone tell me what I did wrong ?
Solution
Question
Any other critique on formatting efficiency will be appreciated
I submitted my answer and only one test case(#5) is giving wrong answer
Can someone tell me what I did wrong ?
Solution
Question
Any other critique on formatting efficiency will be appreciated
One thing that immediately sticks out is that you are not initialising the value of comm
before you check its value.
But that’s the first thing I did in the for loop ?
https://www.codechef.com/viewsolution/26143703
Here is my code
Not able to find any difference between your code and my code
The check is performed before you enter the body of the loop.
So probably a freak case ?
No - I mean you should initialise the value of comm
before you check it XD
I really don’t understand what else you mean
Can you please type it out
Give comm a value before checking its value in any condition! Read about difference between declaration and initialisation.
Thank you so much , your help is very much appreciated but why was this causing error after all eventually a value was gonna go into comm
if you don’t give it a value to begin with, then the initial value of comm
is undefined i.e. it’s allowed to have any value at all, including 0
. If it happens to have the initial value 0
, then the for
loop simply never gets executed at all.