package leetcode;

/**
 * https://leetcode.com/problems/can-i-win/
 */
public class Problem464 {
    public boolean canIWin(int maxChoosableInteger, int desiredTotal) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem464 prob = new Problem464();
        System.out.println(prob.canIWin(10, 11)); // false
        System.out.println(prob.canIWin(4, 6)); // true
    }
}

@@ -12,16 +12,91 @@
 tcode;%0A%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0Aimport java.util.TreeSet;%0A%0A
 /**%0A * h
@@ -265,231 +265,1511 @@
     
-return false;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem464 prob = new Problem464();%0A        System.out.println(prob.canIWin(10, 11)); // false%0A        System.out.println(prob.canIWin(4, 6)); // tru
+Set%3CInteger%3E nums = new TreeSet%3C%3E();%0A        for (int i = 1; i %3C= maxChoosableInteger; i++) %7B%0A            nums.add(i);%0A        %7D%0A        return canIWin(nums, desiredTotal, 0, true);%0A    %7D%0A%0A    private static boolean canIWin(Set%3CInteger%3E nums, int desired, int accu, boolean player1) %7B%0A        if (accu %3E= desired) %7B%0A            if (!player1) %7B%0A                return true;%0A            %7D%0A            return false;%0A        %7D%0A        boolean win = (player1) ? false : true;%0A        for (int num : nums) %7B%0A            Set%3CInteger%3E newNums = new HashSet%3C%3E(nums);%0A            newNums.remove(num);%0A            if (player1) %7B%0A                win %7C= canIWin(newNums, desired, accu + num, !player1);%0A            %7D else %7B%0A                win &= canIWin(newNums, desired, accu + num, !player1);%0A            %7D%0A        %7D%0A        return win;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem464 prob = new Problem464();%0A        System.out.println(prob.canIWin(10, 11)); // false%0A        System.out.println(prob.canIWin(4, 6)); // true%0A        System.out.println(prob.canIWin(10, 100)); // false%0A        System.out.println(prob.canIWin(10, 55)); // false%0A        System.out.println(prob.canIWin(6, 20)); // false%0A        System.out.println(prob.canIWin(6, 15)); // true%0A        System.out.println(prob.canIWin(6, 10)); // true%0A        System.out.println(prob.canIWin(5, 12)); // true%0A        System.out.println(prob.canIWin(5, 15)); // true%0A//        System.out.println(prob.canIWin(20, 200)); // fals
 e%0A  

Update problem 464