Concept Flow - Maximum Product Subarray
Start at first element
Initialize max_prod, min_prod, result
For each element in array
If element < 0, swap max_prod and min_prod
Update max_prod = max(element, max_prod * element)
Update min_prod = min(element, min_prod * element)
Update result = max(result, max_prod)
Repeat for all elements
Return result as max product
We scan the array once, keeping track of the maximum and minimum products ending at each position, swapping them when a negative number appears, and update the result with the maximum product found.
