Skip to content
Veltoryx Technologies
ProProblem 136● Mediumleetcode ↗3 min readUpdated 30 October 2026

Maximum Product Subarray

Track both maximum and minimum running products to handle negative sign reversals in Kadane's algorithm.

01The problem

Given an integer array nums, find a contiguous non-empty subarray within the array that has the largest product, and return that product.

The test cases are generated so that the answer will fit in a 32-bit integer.

Loading the rest of the lesson…