← All problems
Maximum Product Subarray
Given an integer array, find the contiguous subarray with the largest product and return that product. Negative numbers make this trickier than the maximum-sum variant.
Complexity
Time O(n), Space O(1)
Common pitfalls
- Only tracking max (sign flips break it)
- Zero-reset mistakes
Your solution
Log in to save your code and track progress.