My first instinct was greedy, just move each token toward the nearest coin.
Model the problem as a state-space search where each state is the positions of all tokens and the set of collected coins. Use BFS/DFS with memoization to explore all possible move sequences, but optimize by noting that tokens are indistinguishable and moves only increase positions. Alternatively, since tokens never move left, consider dynamic programming over the board from left to right, tracking token positions modulo 3 and coin collection.
Pro tip: Clarify constraints early: ask about the maximum number of tokens and whether tokens can be moved multiple times. This shows you think about edge cases and scalability, which is crucial for a Google interview.
Restate the problem in your own words, confirm the rules (move exactly 3 right, no sharing, coin only on landing), and ask clarifying questions about token count and board size.
Define a state as the tuple of token positions (sorted) and the set of collected coins. A move consists of choosing a token, moving it +3 if the target is empty and within bounds, and updating collected coins if the target has a coin.
Since moves only increase positions, the state graph is a DAG. Use DFS with memoization to compute the maximum coins from each state, or BFS to explore all reachable states and track the max coins.
Note that tokens are indistinguishable, so sort positions. Also, tokens' positions modulo 3 are invariant, which can reduce state space. Consider DP over board index with token positions modulo 3.
Discuss time/space complexity (e.g., O(N * C * 2^C) for DP) and test with small boards, multiple tokens, and coins at unreachable positions.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.