Python two solutions: functional programming and tracking negatives
Calculate the product using reduce and return the sign.\npython\n\tdef arraySign(self, nums: List[int]) -> int:\n        product = reduce(lambda x,y: x*y, nums)
Calculate the product using reduce and return the sign.\n```python\n\tdef arraySign(self, nums: List[int]) -> int:\n        product = reduce(lambda x,y: x*y, nums)\n        return 0 if not product else 1 if product > 0 else -1\n```\n\nIf we encounter a 0, we can return immediately. Otherwise keep track of the negatives. If the count of negatives is odd, the product is negative. If the count of negatives is even, the product is positive.\n```python\n\tdef arraySign(self, nums: List[int]) -> int:\n        result = 1\n        for n in nums:\n            if not n:\n                return n\n\t\t\tif n < 0:\n\t\t\t\tresult = -result\n        return result\n```
['Python', 'Python3']