package leetcode;

/**
 * https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards/
 */
public class Problem1423 {
    public int maxScore(int[] cardPoints, int k) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1423 prob = new Problem1423();
        System.out.println(prob.maxScore(new int[]{1,2,3,4,5,6,1}, 3)); // 12
        System.out.println(prob.maxScore(new int[]{2,2,2}, 2)); // 4
        System.out.println(prob.maxScore(new int[]{9,7,7,9,7,7,9}, 7)); // 55
        System.out.println(prob.maxScore(new int[]{1,1000,1}, 1)); // 1
        System.out.println(prob.maxScore(new int[]{1,79,80,1,1,1,200,1}, 3)); // 202
        System.out.println(prob.maxScore(new int[]{1,79,80,1,1,1,200,1}, 4)); // 281
    }
}

@@ -185,32 +185,588 @@
     
-// TODO%0A        return 0
+return maxScore(cardPoints, k, 0, cardPoints.length - 1,%0A            new Integer%5BcardPoints.length%5D%5BcardPoints.length%5D);%0A    %7D%0A%0A    private static int maxScore(int%5B%5D cardPoints, int k, int i, int j, Integer%5B%5D%5B%5D memo) %7B%0A        if (k == 0) %7B%0A            return 0;%0A        %7D%0A        if (memo%5Bi%5D%5Bj%5D != null) %7B%0A            return memo%5Bi%5D%5Bj%5D;%0A        %7D%0A        int a = maxScore(cardPoints, k - 1, i + 1, j, memo) + cardPoints%5Bi%5D;%0A        int b = maxScore(cardPoints, k - 1, i, j - 1, memo) + cardPoints%5Bj%5D;%0A        int max = Math.max(a, b);%0A        memo%5Bi%5D%5Bj%5D = max;%0A        return max
 ;%0A  

Update problem 1423