@@ -0,0 +1,1549 @@
+public class Solution %7B%0A    public int maxProduct(int%5B%5D nums) %7B%0A        int result;%0A        if(nums.length == 1)%7B%0A            return nums%5B0%5D;%0A        %7D%0A        for(int i = 0; i %3C nums.length; i ++)%7B%0A            if(nums%5Bi%5D == 0)%7B%0A                if(i %3C nums.length - 1)%7B%0A                    result = Math.max(maxProduct(Arrays.copyOfRange(nums, 0, i)), maxProduct(Arrays.copyOfRange(nums, i+1, nums.length)));%0A                %7Delse%7B%0A                    result = maxProduct(Arrays.copyOfRange(nums, 0, i));%0A                %7D%0A                return Math.max(result, 0);%0A            %7D%0A        %7D%0A        return maxProductWoZero(nums);%0A    %7D%0A    %0A    private int maxProductWoZero(int%5B%5D nums)%7B%0A        int first = 0, last = 0, c = 0;%0A        for(int i = 0; i %3C nums.length; i ++)%7B%0A            if(nums%5Bi%5D %3C 0)%7B%0A                if(c == 0)%7B%0A                    c ++;%0A                    first = i;%0A                    last = i;%0A                %7Delse%7B%0A                    c ++;%0A                    last = i;%0A                %7D%0A            %7D%0A        %7D%0A        if(c %25 2 == 0)%7B%0A            return product(nums);%0A        %7Delse%7B%0A            return Math.max(product(Arrays.copyOfRange(nums, 0, last)), product(Arrays.copyOfRange(nums, first+1, nums.length)));%0A        %7D%0A    %7D%0A    %0A    private int product(int%5B%5D nums)%7B%0A        if(nums.length == 0)%7B%0A            return 0;%0A        %7D%0A        double result = 1;%0A        for(int i = 0; i %3C nums.length; i ++)%7B%0A            result *= nums%5Bi%5D;%0A        %7D%0A        return (int)Math.min(result, (double)Integer.MAX_VALUE);%0A    %7D%0A%7D

Q152 Maximum Product Subarray