Back to the 100
Problem 053Dynamic Programming
Medium

Maximum Product Subarray

053

Return the maximum product of a non-empty contiguous subarray.

EXAMPLES

Example 1
Input
{
  "nums": [
    2,
    3,
    -2,
    4
  ]
}

Output
6

FUNCTION SHAPE

nums: intArrayint
00:00
3 local tests readyRun with ⌘/Ctrl + Enter. Your code stays in this browser.

Runs solve(...) locally in a browser worker. SWE Playbook does not submit your code. Only run code you trust; Python code may access the network.