Java easy to understand solution using kadane


#1

public class Solution {
// DO NOT MODIFY THE ARGUMENTS WITH “final” PREFIX. IT IS READ ONLY
public int maxProduct(final int[] nums) {
int curr_max=nums[0];
int curr_min=nums[0];
int final_max=nums[0];
if(nums.length==0)
return 0;
if(nums.length==1)
return nums[0];
for(int i=1;i<nums.length;i++)
{ int temp=curr_max;
curr_max=Math.max(Math.max(curr_maxnums[i],curr_minnums[i]),nums[i]);
curr_min=Math.min(Math.min(tempnums[i],curr_minnums[i]),nums[i]);

    if(curr_max>final_max)
    final_max=curr_max;
    }
    return final_max;
}

}