Skip to content

Commit 0f6dce4

Browse files
add 1822
1 parent dc29c0f commit 0f6dce4

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1822|[Sign of the Product of an Array](https://leetcode.com/problems/sign-of-the-product-of-an-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1822.java) ||Easy|Math|
1112
|1817|[Finding the Users Active Minutes](https://leetcode.com/problems/finding-the-users-active-minutes/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1817.java) ||Medium|HashTable|
1213
|1816|[Truncate Sentence](https://leetcode.com/problems/truncate-sentence/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1816.java) ||Easy|String|
1314
|1814|[Count Nice Pairs in an Array](https://leetcode.com/problems/count-nice-pairs-in-an-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1814.java) ||Medium|Array, HashTable|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _1822 {
4+
public static class Solution1 {
5+
public int arraySign(int[] nums) {
6+
int negativeCount = 0;
7+
for (int num : nums) {
8+
if (num == 0) {
9+
return 0;
10+
} else if (num < 0) {
11+
negativeCount++;
12+
}
13+
}
14+
return negativeCount % 2 == 0 ? 1 : -1;
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)