Given an array of integers nums, you start with an initial positive value startValue.
In each iteration, you calculate the step by step sum of startValue plus elements in nums (from left to right).
Return the minimum positive value of startValue such that the step by step sum is never less than 1.
 
Example 1:
Input: nums = [-3,2,-3,4,2]
Output: 5
Explanation: If you choose startValue = 4, in the third iteration your step by step sum is less than 1.
                step by step sum
                startValue = 4 | startValue = 5 | nums
                  (4 -3 ) = 1  | (5 -3 ) = 2    |  -3
                  (1 +2 ) = 3  | (2 +2 ) = 4    |   2
                  (3 -3 ) = 0  | (4 -3 ) = 1    |  -3
                  (0 +4 ) = 4  | (1 +4 ) = 5    |   4
                  (4 +2 ) = 6  | (5 +2 ) = 7    |   2

Example 2:
Input: nums = [1,2]
Output: 1
Explanation: Minimum start value should be positive. 

Example 3:
Input: nums = [1,-2,-3]
Output: 5

 
Constraints:

1 <= nums.length <= 100
-100 <= nums[i] <= 100

Difficulty: introductory

Starter code:

class Solution:
    def minStartValue(self, nums: List[int]) -> int:
        

Solutions:
class Solution:
    def minStartValue(self, nums: List[int]) -> int:
        res = 1
        for ind,n in enumerate(nums):
            temp = 1-sum(nums[:ind+1])
            if(temp > res):
                res = temp
        return res

class Solution:
    def minStartValue(self, nums: List[int]) -> int:
        minVal=1
        t=0
        for num in nums:
            t+=num
            if(t<0):
                minVal=max(1-t,minVal)
        return minVal
        


class Solution:
    def minStartValue(self, nums: List[int]) -> int:
        pSum = 0
        minSum = 0;
        for num in nums:
            pSum += num
            minSum = min(pSum, minSum)
        return 1 - minSum

class Solution:
    def minStartValue(self, nums: List[int]) -> int:
        num=1; i=0;sum = num;         #flag=False;
        while i<len(nums):
            sum+=nums[i]            
            if sum<1:
                flag = False
                i=0;num+=1;sum=num;   #flag=True
                
            else:
                i+=1
        
            #if i<len(nums) and flag==False:
                #i=0;num+=1;sum=num;flag=True
        
        return num
            


class Solution:
    def minStartValue(self, nums: List[int]) -> int:
        num=1; i=0;sum = num;         #flag=False;
        while i<len(nums):
            sum+=nums[i]            
            if sum<1:
                flag = False
                i=0;num+=1;sum=num;   #flag=True
                
            else:
                i+=1        
        return num
            


class Solution:
    def minStartValue(self, nums: List[int]) -> int:
        n = len(nums)
        
        startValue = 1
        
        while startValue < float('inf'):
            get = True
            tmp = startValue
            for i in range(n):
                if nums[i] + tmp < 1:
                    get = False
                    break
                tmp = nums[i] + tmp
            if not get: 
                startValue += 1
            else:
                return startValue

class Solution:
    def minStartValue(self, nums: List[int]) -> int:
        
        init = 1
        
        
        while init > 0:
            temp = init
            for i in nums:
                temp = temp + i
                if temp <= 0:
                    break
            else:
                return init
            
            
            init += 1

class Solution:
    
    def minStartValue(self, nums: List[int]) -> int:
        start =1
        s=1
        for n in nums:
            s+=n
            if s<1:
                start+=1-s
                s=1
        return start

class Solution:
    def minStartValue(self, nums: List[int]) -> int:
        pref=[0]*len(nums)
        pref[0]=nums[0]
        for i in range(1,len(nums)):
            pref[i]=pref[i-1]+nums[i]
        
        return max(1, 1-min(pref))

class Solution:
    def minStartValue(self, nums: List[int]) -> int:
      
      running_min = nums[0]
      reduction = 0
      for i in nums:
        reduction += i
        running_min = min(running_min, reduction)
      
      return 1 if running_min >= 1 else 1 - running_min

class Solution:
    def minStartValue(self, nums: List[int]) -> int:
        # return -min(0, min(accu for accu in itertools.accumulate(nums))) + 1
        return 1 - min(accumulate(nums, initial=0))

class Solution:
    def minStartValue(self, nums: List[int]) -> int:
        min_sum = 0
        temp = 0
        for num in nums:
            temp += num
            min_sum = min(temp, min_sum)
        
        return abs(min_sum)+1




class Solution:
    def minStartValue(self, nums: List[int]) -> int:
        for i in range(1,1000000):
            flag = 0
            n=i
            for j in nums:
                n+=j
                if n < 1:
                    flag=1
                    break
            if flag==0:
                return i


class Solution:
    def minStartValue(self, nums: List[int]) -> int:
        for i in range(1,1000001):
            flag=0
            sum=i;
            for j in nums:
                sum+=j
                if sum<1:
                    flag=1
                    break
            if flag==0:
                return i


class Solution:
    def minStartValue(self, nums: List[int]) -> int:
        res = 0
        cur = 0
        for num in nums:
            cur += num
            if cur < 1:
                res += 1 - cur
                cur += 1 - cur
        if res == 0:
            return 1
        return res