Maximum Product Subarray

Problem Find the contiguous subarray with the largest product and return that product.

Input / Output

  • Input: an integer array nums (may contain negatives and zeros).
  • Output: the maximum product over all contiguous subarrays.

Constraints

  • 1 ≤ n ≤ 2 × 10^4.
  • The answer fits in a 32-bit integer.

Example

  • [2,3,-2,4] → 6 (subarray [2,3])
added …
LeaderboardSalaryAccount