package leetcode;

/**
 * https://leetcode.com/problems/stone-game/
 */
public class Problem877 {
    public boolean stoneGame(int[] piles) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem877 prob = new Problem877();
    }
}

@@ -147,133 +147,908 @@
     
-// TODO%0A        return false;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem877 prob = new Problem877();
+int sum = 0;%0A        for (int i = 0; i %3C piles.length; i++) %7B%0A            sum += piles%5Bi%5D;%0A        %7D%0A        int max = stoneGame(piles, 0, piles.length - 1);%0A        System.out.println(max);%0A        return max %3E= sum - max;%0A    %7D%0A%0A    private static int stoneGame(int%5B%5D piles, int i, int j) %7B%0A        if (i %3E= j) %7B%0A            return 0;%0A        %7D%0A        int val = stoneGame(piles, i + 1, j - 1);%0A        int a = val + piles%5Bi%5D;%0A        int b = val + piles%5Bj%5D;%0A        return Math.max(a, b);%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem877 prob = new Problem877();%0A        System.out.println(prob.stoneGame(new int%5B%5D%7B5, 3, 4, 5%7D)); // true%0A//        System.out.println(prob.stoneGame(new int%5B%5D%7B5, 3, 4, 6%7D)); // true%0A//        System.out.println(prob.stoneGame(new int%5B%5D%7B1, 1, 1, 1%7D)); // true%0A//        System.out.println(prob.stoneGame(new int%5B%5D%7B7, 3, 8, 2, 9, 10%7D)); // true
 %0A   

Update problem 877