MEDIUMasked at 1 company

Flip Game II

A medium-tier problem at 52% community acceptance, tagged with Math, Dynamic Programming, Backtracking. Reported in interviews at Google and 0 others.

Founder's read

Flip Game II is a medium-difficulty game theory problem that appears in Google interviews. You're given a string and two players take turns flipping adjacent characters. The player who can't move loses. It's deceptively simple to describe but tricky to solve correctly. About half the candidates who attempt it pass, which means the other half hit a wall on pattern recognition or state exploration. If you blank on the optimal approach during your OA, StealthCoder solves it in seconds invisible to the proctor.

Companies asking
1
Difficulty
MEDIUM
Acceptance
52%

Companies that ask "Flip Game II"

If this hits your live OA

Flip Game II is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.

Get StealthCoder
What this means

The trap is trying to simulate the game greedily or checking win/loss with a simple formula. You actually need to explore all possible game states recursively and cache results. For each board state, you generate every legal move, then check if any move puts your opponent in a losing position. If yes, you win. If all moves lead to opponent wins, you lose. Memoization is critical because the same board state can be reached via different move sequences. Backtracking generates the move tree, Dynamic Programming or memoization prevents recomputation. Game Theory ties it together: you're not optimizing a single outcome, you're finding winning and losing positions relative to whose turn it is. This is where candidates usually get stuck. StealthCoder is the safety net if the game-state recursion pattern doesn't click during the live assessment.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Flip Game II recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Flip Game II interview FAQ

Is Flip Game II actually asked at top companies?+

Yes. Google has reported asking it. It's less common than array or tree problems, so many candidates skip it during prep. That gap is exactly when you hit it live.

What's the trick I'm missing if I fail?+

You need to model every reachable game state and cache win/loss results by board configuration, not by a single metric. The trick is recognizing that a position is a win if ANY move leaves opponent in a losing position. Greedy moves don't work.

Do I need to code all five topics or just one?+

The core solution uses Backtracking to explore moves and Memoization to avoid recomputing identical board states. Game Theory is the conceptual framework. Math and Dynamic Programming describe the approach, but the implementation centers on recursion plus caching.

How do I know if my solution is efficient enough?+

Without memoization, you'll time out on large inputs because you recompute the same board states repeatedly. With memoization, you prune the search significantly. If your recursion revisits the same string many times without caching, it's not correct.

What if I can't figure out the game theory part?+

Start by writing a function that checks whether a given board state is a win for the current player. Then recursively check all possible next moves. If any move lands opponent in a losing state, current player wins. Build from that base case.

Want the actual problem statement? View "Flip Game II" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.