We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d4ba403 commit 35d4f2fCopy full SHA for 35d4f2f
Easy/Sign of the Product of an Array.java
@@ -0,0 +1,6 @@
1
+class Solution {
2
+ public int arraySign(int[] nums) {
3
+ return Arrays.stream(nums).filter(num -> num == 0).map(e -> 0).findAny()
4
+ .orElse(Arrays.stream(nums).filter(num -> num < 0).count() % 2 == 0 ? 1 : -1);
5
+ }
6
+}
0 commit comments