Answer: GitHub SWE Interview Question 2022 December | Arrays and Dynamic Programming | o

Answer · Posted Jun 2026

Solution: Track Both Maximum and Minimum Running Products Approach Unlike the maximum subarray sum problem (Kadane's), products are tricky because a large negative product can become the maximum when multiplied by another negative number. So at every step, track both maxProd (the maximum product ending at current index) and minProd (the minimum — most negative — product ending at current index). At each element, the new max could come from: current element alone, current element times old maxProd (positive times ...

The full answer & interview discussion are available to premium members.

Log in Create a free account