Can I Win

In a modified '100 game', two players take turns adding a unique integer from 1 to maxChoosableInteger to a running total. The player who causes the total to reach or exceed the desiredTotal wins. Determine if the first player can force a win assuming both play optimally.

Constraints

  • 1 <= maxChoosableInteger <= 20
  • 0 <= desiredTotal <= 300
Saving… · 3 lines
class Solution:
def canIWin(self, maxChoosableInteger, desiredTotal) -> bool:
Console

Click Run to execute sample tests.