minSum
to 0 and currentSum
to 0.nums
array.
a. Add the current number to currentSum
.
b. Update minSum
to be the minimum of minSum
and currentSum
.minSum
is less than 0, return 1 - minSum
as the minimum starting value. This ensures that the running sum will be adjusted to never drop below 1.minSum
is 0 or positive, return 1 as the minimum starting value.