Dashboard
LC #152
Maximum Product Subarray
Pattern · ?AmazonLinkedInGoogleMeta
Problem
Find the contiguous subarray with the largest product. The array may contain negative numbers and zeros.
Constraints
- 1 ≤ nums.length ≤ 2×10⁴
- -10 ≤ nums[i] ≤ 10
- Product fits in a 32-bit integer
Example
- Input
- nums = [2, 3, -2, 4]
- Output
- 6
- Why
- [2,3] has the largest product = 6
Spot the pattern
Which pattern cracks it?
Hints
One at a time