Dsa
Math
Medium
Maximal Product Subarray
Given an integer array nums, find the maximum product of a contiguous subarray.
For example, given the input:
[2,3,-2,4]
The output should be:
6 (because the subarray [2,3] has the maximum product of 6).
Input format:
- The first line contains an integer n (1 ≤ n ≤ 1000) — the length of the array.
- The second line contains n space-separated integers, representing the elements of the array nums.
Output format:
- A single integer representing the maximum product of any contiguous subarray.
Key concepts
arraymathproduct
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