乘积最大子序列

public class Solution {
/*
* @param nums: An array of integers
* @return: An integer
*/
public int maxProduct(int[] nums) {
// write your code here
int max = nums[0];
int index = 1;
while(index <= nums.length){
for(int i = 0;i< = nums.length-index;i++){
int product = 1;
for(int j=0;j<index;j++){
product *= nums[i+j];
}

          if(product > max)
                 max = product;
        }
        index ++;
    }
    return max;
}

};

posted @ 2017-08-22 02:29  逸文皓  阅读(71)  评论(0编辑  收藏  举报