Welcome to the Flip Game II - a strategic two-player game that tests your ability to think ahead!
You and your friend are playing with a string currentState containing only '+' and '-' characters. On each turn, a player must flip two consecutive "++" into "--". The game continues until no more moves are possible.
The Challenge: Determine if the starting player (you) can guarantee a win with optimal play from both sides.
Rules:
- Players take turns flipping consecutive
"++"to"--" - The player who cannot make a move loses
- Both players play optimally
Goal: Return true if you (the first player) can guarantee a win, false otherwise.
Example: For "+++", you can flip the first two to get "-++", then your opponent has no moves left - you win!
Input & Output
Visualization
Time & Space Complexity
Same as memoized version but with constant factor improvements
Hash table with optimized string storage
Constraints
- 1 โค currentState.length โค 60
-
currentState[i] is either
'+'or'-' - Both players play optimally