factors. Imagine multiplying all of its elements together and determine the sign of the result.
Return 1 if the product is positive, -1 if it is negative, and 0 if it equals zero.
Note that in most languages the product itself overflows ordinary integer types, so it is better to find the sign without computing it.factors=[3, -2, 5, -1] → 1
The product is 30: two negative factors cancel out, so the answer is 1.
factors=[-4, 9, 0, -7] → 0
One of the factors is zero, so the whole product is 0.
factors=[-6] → -1
The only factor is negative, so the answer is -1.
len(factors) ≤ 2·10⁵factors[i] ≤ 1000factors=[3, -2, 5, -1]
1
Run checks the first 3 tests in your browser. Submit checks all 97 tests on the server, hidden ones included.