- time: O(n*n), using two for loops
class Solution {
public int maxProduct(int[] nums) {
//O(n*n)
if(nums.length==0) return 0;
int max = nums[0];
for(int i = 0; i<nums.length; i++){
int mul = 1;
for(int j = i; j<nums.length; j++){
mul *= nums[j];
max = Math.max(mul, max);
}
}
return max;
}
}