There is a function signFunc(x) that returns:


	1 if x is positive.
	-1 if x is negative.
	0 if x is equal to 0.


You are given an integer array nums. Let product be the product of all values in the array nums.

Return signFunc(product).

&nbsp;
Example 1:

Input: nums = [-1,-2,-3,-4,3,2,1]
Output: 1
Explanation: The product of all values in the array is 144, and signFunc(144) = 1


Example 2:

Input: nums = [1,5,0,2,-3]
Output: 0
Explanation: The product of all values in the array is 0, and signFunc(0) = 0


Example 3:

Input: nums = [-1,1,-1,1,-1]
Output: -1
Explanation: The product of all values in the array is -1, and signFunc(-1) = -1


&nbsp;
Constraints:


	1 &lt;= nums.length &lt;= 1000
	-100 &lt;= nums[i] &lt;= 100


class Solution:
    def arraySign(self, nums: List[int]) -> int:
		return 0 if 0 in nums else -1 if sum(x < 0 for x in nums) % 2 else 1
class Solution {
    public int arraySign(int[] nums) {
        int prod=1;
        for(int i=0;i<nums.length;i++){
            int val=signFunc(nums[i]);
            prod*=val;
        }
        return prod;
    }
    
    private int signFunc(int x){
        if(x<0) return -1;
        else if(x>0) return 1;
        return 0;
    }
}
class Solution {
public:
    int arraySign(vector<int>& nums) {
        int res = 1;
        for(auto x : nums)
        {
            if(x < 0) res *= -1;
            else if(x == 0) return 0;
        }
        return res;
    }
};
var arraySign = function(nums) {
    // use filter to find total negative numbers in the array
    let negativeCount = nums.filter(n => n<0).length;

    // check if the nums array has zero. If it does, then return 0
    if(nums.includes(0)) return 0;

    // If negativeCount variable is even answer is 1 else -1
    return negativeCount % 2 === 0 ? 1 : -1
};
Sign of the Product of an Array