Sign of the Product of an Array
给一个数组, 求里面的数字乘积是正负还是0.
class Solution {
public int arraySign(int[] nums) {
int count = 0;
for(int n : nums){
if(n < 0)
count++;
if(n == 0)
return 0;
}
return count % 2 == 0 ? 1 : -1;
}
}