values. Find the longest contiguous span whose elements multiply to a strictly positive number, and return its length.
If there is no such span, return 0.
You do not need the product itself, which may be huge; only its sign matters.values=[3, -1, 0, -2, -5, 4, -1] → 3
After the zero comes [-2, -5, 4]: two negatives cancel out, the product is 40 > 0, length 3. Adding the final -1 would make three negatives.
values=[-7] → 0
The only element is negative, so no positive product is possible and the answer is 0.
values=[2, -3, 1, 6, 0, 5] → 2
values=[3, -1, 0, -2, -5, 4, -1]
3
Run checks the first 3 tests in your browser. Submit checks all 125 tests on the server, hidden ones included.