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

Commit2f82abd

Browse files
committed
Added Maximum Product of Two Elements in an Array.java
1 parent9fd78fb commit2f82abd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
classSolution {
2+
intmaxOne =Integer.MIN_VALUE;
3+
intmaxTwo =Integer.MIN_VALUE;
4+
publicintmaxProduct(int[]nums) {
5+
for (intnum :nums) {
6+
if (maxOne <num) {
7+
maxTwo =maxOne;
8+
maxOne =num;
9+
}
10+
elseif (maxTwo <num) {
11+
maxTwo =num;
12+
}
13+
}
14+
return (maxOne -1) * (maxTwo -1);
15+
}
16+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp