LeetCode solutions

1950. Sign of the Product of an Array

My accepted Python solution to LeetCode problem 1950, Sign of the Product of an Array, running in 2ms.

  • Difficulty: Easy
  • Python
  • Runtime 2ms
  • Memory 17.6MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 2ms, memory 17.6MB, accepted 2025-12-30.

python
class Solution:
    def arraySign(self, nums: List[int]) -> int:
        sign = 1
        for num in nums:
            if num == 0:
                return 0
            if num < 0:
                sign *= -1
        return sign

Source