Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit35d4f2f

Browse files
authored
Added Sign of the Product of an Array.java
1 parentd4ba403 commit35d4f2f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
classSolution {
2+
publicintarraySign(int[]nums) {
3+
returnArrays.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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp