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
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 2ms, memory 17.6MB, accepted 2025-12-30.
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