Maximum Product Subarray

Problem:

Find the contiguous subarray within an array (containing at least one number) which has the largest product.

Examples:

Given the array [2,3,-2,4]

The contiguous subarray [2,3] has the largest product = 6.

Note:
It's recommended to do the “MAXIMUM CONTIGUOUS SUBARRAY” BEFORE THIS PROBLEM.

Hints and Answer Checklist