1
2
3
4
5
6
7
8
|
pythonclass Solution:
def arraySign(self, nums: List[int]) -> int:
cnt=1
for i in nums:
cnt*=i
if cnt>0 : return 1
elif cnt ==0 : return 0
else : return -1
|
cs |
문제 자체가 크게 어렵지 않아요
입력받은 리스트의 하나하나 곱한것의 부호 에 따라서 리턴해주면 되는 문제입니다.
반응형
'python-algorithm' 카테고리의 다른 글
Leetcode Add Strings (0) | 2021.08.19 |
---|---|
Leetcode 4. Median of Two Sorted Arrays (0) | 2021.08.19 |
Leetcode 344. Reverse String (0) | 2021.08.17 |
Leetcode 1832. Check if the Sentence Is Pangram (0) | 2021.08.17 |
Leetcode 1662. Check If Two String Arrays are Equivalent (0) | 2021.08.17 |
댓글