Code Room
CodingEasycod-g1478
Subject Dynamic programming 1dLevel Entry–Mid~10 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Given a non-empty list of integers (positive, negative, or zero), return the smallest possible sum of any contiguous run of one or more elements. This is the mirror image of the maximum-subarray problem: instead of the best stretch you are hunting for the worst one. For example, in [3, -4, 2, -3, -1, 7] the run [-4, 2, -3, -1] has sum -6, and no contiguous run sums lower.

Implement
min_subarray_sum(nums: list[int]) → int
Examples
in[[3,-4,2,-3,-1,7]]out-6
in[[2,2,2]]out2
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.