SSalesforce·DSASMTSOnline Assessment
Maximum Product Subarray
Problem
Find the contiguous subarray with the largest product.
Example
[2,3,-2,4] -> 6
Constraints
- 1 ≤ n ≤ 2 × 10^4
Approach
Track running max and min (sign flips on negatives). O(n). Reported Salesforce OA question.
added 6 days ago