My issue
i think we just need two cases: if the multiple >= 0 or not
then if it’s smaller than 0 → remove 1 number (negative)
My code
#include <iostream>
using namespace std;
int main() {
// your code goes here
int testcase;
cin >> testcase;
while(testcase--)
{
int N, multiple = 1; //Numbers of factors in the array
cin >> N;
int originalArr[N];
for (int i = 0; i < N; i++) {
cin >> originalArr[i];
}
for (auto i : originalArr) {
multiple*=i;
}
if(multiple >= 0)
{
cout << 0 << '\n';
}
else
{
cout << 1 << '\n';
}
}
return 0;
}
Problem Link: NONNEGPROD Problem - CodeChef