class Solution:
def arraySign(self, nums: List[int]) -> int:
if 0 in nums:
return 0
len_n = 0
for n in nums:
if n < 0:
len_n = len_n +1
return -1 if len_n % 2 else 1
'CS > 알고리즘' 카테고리의 다른 글
[Leetcode] 2215. Find the Difference of Two Arrays (0) | 2023.05.03 |
---|---|
[Leetcode] 1491. Average Salary Excluding the Minimum and Maximum Salary (0) | 2023.05.02 |
[Leetcode] 121. Best Time to Buy and Sell Stock (0) | 2023.05.02 |
[Leetcode 334] 334. Increasing Triplet Subsequence (0) | 2023.05.02 |
[Leetcode] 162. Find Peak Element (0) | 2023.05.02 |