Maximum Product Subarray
Find the contiguous subarray with the largest product. A negative number can turn the smallest product into the largest, so track both the maximum and the minimum product ending at each index.
Spotted a mistake in this lesson?Report an issue →