Code RoomMinimum subarray sum
EasyPrep Room Coding #680

Minimum subarray sum

CodingAlgorithms & data structuresEntry–Mid~10 min

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.

0:00 of about 10 min
InputExpectedGot
[[3,-4,2,-3,-1,7]]-6not run yetsample
[[2,2,2]]2not run yetsample