As reported: D. E. Shaw SMT screening (2026): one DSA question, a DP problem — maximum product subarray — between a project discussion and Python questions.
This is LeetCode 152 — Maximum Product Subarray. Our write-up: /maximum-product-subarray.
Given an integer array nums, find a non-empty contiguous subarray with the largest product and return the product. The answer fits in a 32-bit integer.
Example 1
nums = [2,3,-2,4]
Output: 6
Example 2
nums = [-2,0,-1]
Output: 0
Constraints: 1 ≤ nums.length ≤ 2 · 10^4; -10 ≤ nums[i] ≤ 10; the product of any subarray fits in a 32-bit integer.
Code runner format: one JSON value per line: nums. Implement maxProduct(nums).