Is zero positive or negative ? Alternative Array Subprefix

Hi, I think I have a problem with this question, not sure what to do when the input is zero, since it didn’t say that the input couldn’t be zero, anyways I made two codes, one where there is no output for zero, and one where I consider zero to be positive, both are wrong…
here’s my list of codes

edit : the code that probably mattered, are the codes where I got WA

Zero is neither positive and nor negative. And I assumed that they would not give 0 in the input and got AC. There is some flaw in your code. Debug carefully and you will find it. Do read the question again.

well, there is no guarantee that it is not going to be zero, and regarding the bug I will try to find it. Damn it, I hate subtle bugs

As mentioned in answers Zero is neither positive and nor negative .
A pro tip and a quick hack - Add these lines in your code.



scanf( "%d", &arr[ i ] );
if(arr[i]==0) while(1);


And perform only input no computations for answer. WA or TLE will tell you whether 0 is included in test cases or not.

1 Like

yaaas, I finally succeeded the problems, after two days of trying

1 Like