PREP48 Editorial

Problem Explanation

You are given an array A, and you have to output the maximum product among all the subarrays of that array

Approach

We use Kadane’s Algorithm to find the maximum product among the array. We first iterate over the array normally and keep multiplying the current element in a product variable. At each iteration we store the maximum of the product variable in a maxproduct variable. Then we iterate backwards through the array and do the same procedure.