Skip to content

Commit

Permalink
Merge pull request #2645 from flashzzz/patch-1
Browse files Browse the repository at this point in the history
Create 1822-sign-of-the-product-of-an-array.py
  • Loading branch information
tahsintunan committed Jun 29, 2023
2 parents 8822cd5 + 0621b97 commit d6fdecf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions python/python/1822-sign-of-the-product-of-an-array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Solution:
def arraySign(self, nums: List[int]) -> int:
flag = True
for i in nums:
if i == 0:
return 0
if i < 0:
flag = not flag

return 1 if flag else -1

0 comments on commit d6fdecf

Please sign in to comment.