Implement the method productSign that returns the sign of the product of an integer array.
Return 1 for a positive product, -1 for a negative product, and 0 if the product is zero.
The task is designed to test careful handling of edge cases, not only the most common input.
- Do not multiply all values directly because large products can overflow.
- Return
0as soon as a zero is found. - An odd count of negative values means the product is negative.
Scan once, checking for zero and counting negative numbers.