You are given two integers, maxChoosableInteger and desiredTotal.
Two players take turns choosing an unused integer from maxChoosableInteger. Each chosen integer is added to a running total. The player whose choice makes the running total greater than or equal to desiredTotal wins.
Both players play optimally. Return true if the first player can force a win; otherwise, return false.
Implement canIWin(maxChoosableInteger, desiredTotal). The parameter maxChoosableInteger is an integer, desiredTotal is an integer, and the method returns a boolean.
Constraints:
maxChoosableInteger
desiredTotal $\leq 300`
You are given two integers, maxChoosableInteger and desiredTotal.
Two players take turns choosing an unused integer from maxChoosableInteger. Each chosen integer is added to a running total. The player whose choice makes the running total greater than or equal to desiredTotal wins.
Both players play optimally. Return true if the first player can force a win; otherwise, return false.
Implement canIWin(maxChoosableInteger, desiredTotal). The parameter maxChoosableInteger is an integer, desiredTotal is an integer, and the method returns a boolean.
Constraints:
maxChoosableInteger
desiredTotal $\leq 300`