Medium · Arrays

Maximum Product Subarray

Given a non-empty integer array nums, return the largest product of any non-empty contiguous subarray.

Examples

Example 1

[2,3,-2,4]

Output: 6

Example 2

[-2,3,-4]

Output: 24

Rebuild it in the studio

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Arrays problems