Skip to content

Commit 7a7c9fd

Browse files
committed
Runtime: 2 ms (Top 99.90%) | Memory: 54.7 MB (Top 23.03%)
1 parent 30576de commit 7a7c9fd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Runtime: 2 ms (Top 99.90%) | Memory: 54.7 MB (Top 23.03%)
12
class Solution {
23
public int maximumProduct(int[] nums) {
34
int min1 = Integer.MAX_VALUE, min2 = Integer.MAX_VALUE;
@@ -6,20 +7,20 @@ public int maximumProduct(int[] nums) {
67
if (n <= min1) {
78
min2 = min1;
89
min1 = n;
9-
} else if (n <= min2) { // n lies between min1 and min2
10+
} else if (n <= min2) { // n lies between min1 and min2
1011
min2 = n;
1112
}
12-
if (n >= max1) { // n is greater than max1, max2 and max3
13+
if (n >= max1) { // n is greater than max1, max2 and max3
1314
max3 = max2;
1415
max2 = max1;
1516
max1 = n;
16-
} else if (n >= max2) { // n lies betweeen max1 and max2
17+
} else if (n >= max2) { // n lies betweeen max1 and max2
1718
max3 = max2;
1819
max2 = n;
19-
} else if (n >= max3) { // n lies betwen max2 and max3
20+
} else if (n >= max3) { // n lies betwen max2 and max3
2021
max3 = n;
2122
}
2223
}
2324
return Math.max(min1 * min2 * max1, max1 * max2 * max3);
2425
}
25-
}
26+
}

0 commit comments

Comments
 (0)