Skip to content

Commit d6fdecf

Browse files
authored
Merge pull request neetcode-gh#2645 from flashzzz/patch-1
Create 1822-sign-of-the-product-of-an-array.py
2 parents 8822cd5 + 0621b97 commit d6fdecf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def arraySign(self, nums: List[int]) -> int:
3+
flag = True
4+
for i in nums:
5+
if i == 0:
6+
return 0
7+
if i < 0:
8+
flag = not flag
9+
10+
return 1 if flag else -1

0 commit comments

Comments
 (0)