Reported September 2026
Googlegreedy

Maximum Coins With Moving Tokens

Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Google OA. Under 2s to a working solution.
Founder's read

N tops out at 100, which tempts you to simulate every move sequence. Don't. With several tokens and repeated jumps, the number of board states explodes fast. This Google OA, reported in September 2026, is a disguised residue-class problem. A token only ever jumps three cells, so the board splits into three independent lanes by index mod 3. Once you see that, the whole thing is a short scan with no search at all. Candidates who miss it burn the clock on backtracking that never finishes cleanly. If you blank on the lane idea mid-assessment, StealthCoder runs invisibly on your screen and hands you the approach as a safety net.

The problem

There is a single-player board game with N positions described by a string board. Each position is empty ('.'), contains a player's token ('T'), or contains a coin ('C'). The player may have multiple tokens.
A coin is collected when a token is placed on the coin's position. Each coin can be collected only once.
In one turn, the player may move one token exactly three positions to the right. The token does not stop on the positions in between, and every token may be moved multiple times. A token cannot be moved if another token already occupies its destination.
Return the maximum number of coins the player can collect.
Implement solution(board), where board is a string of length N.

Function
solution(board: String) → int

Examples
Example 1
board = "TT.T.CCCCC"
return = 3
The player can move the third and second tokens twice, collecting three coins in total:
"TT.T.CCCCC" -> "TT...CTCCC" -> "TT...C.CCT" -> "T...TC.CCT" -> "T....C.TCT".
It is still possible to move the first token, but it cannot collect any coins.
Example 2
board = "T...CCCC"
return = 1
Example 3
board = "C..TT.CT.C"
return = 2

Constraints
N is an integer within the range [1..100].
String board consists only of the characters '.', 'T' and/or 'C'.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Split positions by index mod 3. Inside one lane, tokens move only right, one step of the lane at a time, and they can't pass each other because the landing cell must be empty. The key claim: in each lane, every coin at or to the right of the leftmost token can be collected. The rightmost token runs to the end, then the next one follows behind it, and so on, so together they sweep the whole stretch from the first token onward. Coins left of the first token in a lane are lost forever. So the answer is the sum, per lane, of coins at positions at or after that lane's first token. Lanes with no token give zero. Check example 1: lane 0 gives 2, lane 1 gives 1, lane 2 gives 0, total 3. The pitfall is trying to simulate blocking. If you freeze on the proof, StealthCoder is the hedge during the live OA.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Maximum Coins With Moving Tokens cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Google's OA.

Google reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Maximum Coins With Moving Tokens FAQ

What's the trick in Maximum Coins With Moving Tokens?+

Jumps of exactly three mean the board splits into three independent lanes by index mod 3. Within a lane, find the first token. Every coin in that lane at or after that position is collectable. Sum across lanes. That's one pass, O(N), no simulation needed.

How hard is this Google OA question really?+

The code is tiny, maybe ten lines. The difficulty is the insight that lanes are independent and that blocking never costs you coins. If you try to simulate moves or search states, it feels hard. Once you see the lanes, it's an easy problem.

Why doesn't one token blocking another lose coins?+

Tokens in a lane keep their order, but the front token can run to the end first and the others follow behind it. Every lane cell from the first token onward ends up visited by some token. Blocking only affects ordering, not total coverage.

What edge cases should I test?+

Test a board with no tokens (answer 0), a board with no coins, and coins sitting left of every token in their lane. Also test a coin on the same index as a token's start, and a length-1 board. Then verify the three examples: 3, 1 and 2.

How do I prepare for this in 48 hours?+

Practice spotting when a fixed jump size splits an array into independent residue classes. Then write the per-lane scan from memory: track the first token seen in each of the three lanes, and count coins once a lane has a token. Run the three given examples by hand.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Google.

OA at Google?
Invisible during screen share
Get it