Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Split the whole array into subarrays by zeroes since a subarray with positive product cannot contain any zero.
If the subarray has even number of negative numbers, the whole subarray has positive product.
Otherwise, we have two choices, either - remove the prefix till the first negative element in this subarray, or remove the suffix starting from the last negative element in this subarray.