Skip to content

Commit f230bb3

Browse files
committed
Auto Update@2019-04-1411:06:34.30
1 parent 2c1e646 commit f230bb3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
public class Solution {
3+
4+
public int maxProduct(int[] nums) {
5+
int max = nums[nums.length - 1];
6+
for (int i = 0; i < nums.length; i++) {
7+
int temp = 1;
8+
for (int j = i; j < nums.length; j++) {
9+
temp = temp * nums[j];
10+
if (temp > max) {
11+
max = temp;
12+
}
13+
if (temp == 0) {
14+
break;
15+
}
16+
}
17+
}
18+
return max;
19+
}
20+
21+
public static void main(String[] args) {
22+
int[] nums = {-3,0,1,-2};
23+
System.out.println(new Solution().maxProduct(nums));
24+
}
25+
}

0 commit comments

Comments
 (0)