package leetcode;

/**
 * https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum/
 */
public class Problem1413 {
    public int minStartValue(int[] nums) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1413 prob = new Problem1413();
        System.out.println(prob.minStartValue(new int[]{-3,2,-3,4,2})); // 5
        System.out.println(prob.minStartValue(new int[]{1,2})); // 1
        System.out.println(prob.minStartValue(new int[]{1,-2,-3})); // 5
    }
}

@@ -183,350 +183,231 @@
     
-// TODO%0A        return 0
+int sum = 0;%0A        int min = Integer.MAX_VALUE
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1413 prob = new Problem1413();%0A        System.out.println(prob.minStartValue(new int%5B%5D%7B-3,2,-3,4,2%7D)); // 5%0A        System.out.println(prob.minStartValue(new int%5B%5D%7B1,2%7D)); // 1%0A        System.out.println(prob.minStartValue(new int%5B%5D%7B1,-2,-3%7D)); // 5
+for (int num : nums) %7B%0A            sum += num;%0A            min = Math.min(min, sum);%0A        %7D%0A        int answer = 1 - min;%0A        return answer %3C= 0 ? 1 : answer;
 %0A   

Solve problem 1413