Dsa
Arrays
Easy
Max Product Subarray
Given an array of integers, find the maximum product of a contiguous subarray. The input format is as follows:
Input:
- The first line contains a single integer n (1 <= n <= 1000) - the number of elements in the array.
- The second line contains n space-separated integers, the elements of the array.
Output:
- Print the maximum product of any contiguous subarray.
Example:
Input:
5
2 3 -2 4 -1
Output:
6
Key concepts
arrayssubarraysproducts
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now