Minimum Subarray Sum
Problem statement
Given a nonempty integer array nums, return the smallest sum of any nonempty contiguous subarray.
A subarray consists of consecutive elements. Return its sum, rather than its length or indices. There is no target-sum parameter.
Function
minimumSubarraySum(nums: int[]) → longExamples
Example 1
nums = [3,-4,2,-3,-1,7,-5]return = -6The subarray [-4, 2, -3, -1] has sum -6.
Example 2
nums = [2,4,1]return = 1The smallest nonempty sum is the single element 1.
Example 3
nums = [-5]return = -5The only nonempty subarray has sum -5.
Constraints
1 <= nums.length <= 10^5-10^9 <= nums[i] <= 10^9- The answer fits a signed 64-bit integer.