Find the smallest sum of any subarray
Your task
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.
Examples
min_subarray_sum(nums: list[int]) -> intExample 1
Input
min_subarray_sum([3, -4, 2, -3, -1, 7])Output
-6Example 2
Input
min_subarray_sum([2, 2, 2])Output
2