1822. Sign of the Product of an Array

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1822

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