Skip to content

Commit eeee241

Browse files
Merge pull request neetcode-gh#2618 from leahjia/1822-sign-of-the-product-of-an-array
Create 1822-sign-of-the-product-of-an-array.java
2 parents e863fa4 + 56d6a94 commit eeee241

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+
public int arraySign(int[] nums) {
3+
int sign = 1;
4+
for (int i : nums) {
5+
if (i == 0) return 0;
6+
if (i < 0) sign *= -1;
7+
}
8+
return sign;
9+
}
10+
}

0 commit comments

Comments
 (0)