Two players take turns choosing a number from 1 to maxChoosableInteger without reuse. The running sum increases by the chosen number. Return true if the first player can force a win by reaching or exceeding desiredTotal. Pattern focus: Bitmask DP. Encode which numbers are already used and memoize winning states.
maxChoosableInteger = maximum number available, desiredTotal = target sum
true if the first player can force a win
Example 1:
Input:
maxChoosableInteger = 10 desiredTotal = 11
Output:
false
Explanation:
No guaranteed winning strategy exists for the first player.
Example 2:
Input:
maxChoosableInteger = 10 desiredTotal = 0
Output:
true
Explanation:
The target is already reached before any move is made.
Example 3:
Input:
maxChoosableInteger = 5 desiredTotal = 4
Output:
true
Explanation:
The first player can choose 4 immediately and win.