Maximum Product Subarray Problem

Maximum Product Subarray Problem — ExecCode Medium DSA Practice

Solve the Maximum Product Subarray problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Given an integer array nums, find a subarray that has the largest product, and return the product. For Maximum Product Subarray, focus on the exact input variables, return only the requested value, and preserve the required time complexity for the intended pattern.

Examples

Input nums = [2, 3, -2, 4]; Output 6

Constraints

1 ≤ nums.length ≤ 2·10^4 -10 ≤ nums[i] ≤ 10 Product fits in 32-bit integer

Practice Maximum Product Subarray free on ExecCode. Browse DSA problems, topic map, and placement guides.