Dev
Mentor
Coach Interview AI
Mock Interview AI
Coding Problems
Blog
Pricing
Toggle theme
Sign In
Get Started
Toggle theme
Loading...
For the best coding experience, use a desktop browser.
Medium
Array
Maximum Product Subarray
Find the contiguous subarray with the largest product and return that product.
Examples
Input:
nums = [2,3,-2,4]
Output:
6
Sample Test Cases
Case 1 Input:
[2,3,-2,4]
Expected:
6
Case 2 Input:
[-2,0,-1]
Expected:
0
Reset
Run
Submit
Loading editor...
Test Case
Output
Submission
Case 1 Input:
[2,3,-2,4]
Expected:
6
Case 2 Input:
[-2,0,-1]
Expected:
0