← Google Interview Insights

Google·Software Engineer·Onsite - Coding / Algorithms·Intermediate

Intermediate
Apr 2026

Summary

Got a Google SWE coding round with a board game simulation problem. Tricky enough that I had to think carefully about state space and collision constraints, not just greedy moves.

Questions Asked (1)

Q1

Given a board string with tokens ('T') and coins ('C'), where each token can move exactly 3 positions to the right per turn and cannot land on another token, find the maximum number of coins collectible through an optimal sequence of moves.

Algorithms & Data Structures
Author's notes

My first instinct was greedy, just move whatever token is closest to a coin.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a state-space search where each state is the board configuration, and use dynamic programming or BFS to explore all possible sequences of moves. Since tokens move exactly 3 positions right and cannot overlap, the state space is manageable; compute the maximum coins collected by considering each token's choices and interactions.

Pro tip: Clarify the rules upfront: ask whether tokens can move off the board, whether coins are removed after collection, and whether tokens can move past each other. This shows attention to detail and prevents solving the wrong problem.

1. Clarify rules and constraints

Ask clarifying questions about board size, token movement limits, coin collection mechanics, and whether tokens can share positions or move off the board.

2. Define state and transitions

Represent the board as a string and define a state as the positions of all tokens and remaining coins. A move consists of advancing one token by 3 positions if the target is empty or contains a coin.

3. Choose an algorithm

Use dynamic programming with memoization or BFS/DFS with state hashing to explore all reachable states and compute the maximum coins collected.

4. Optimize and handle edge cases

Consider pruning symmetric states, using bitmasks for token positions, and handling cases where tokens block each other or no moves are possible.

5. Analyze complexity and test

Discuss time and space complexity, and walk through small examples to verify correctness and performance.

Key Points to Mention

  • State representation: board string, token positions, collected coins
  • Move generation: exactly 3 steps right, cannot land on another token
  • Dynamic programming or BFS with memoization to avoid recomputation
  • Bitmask or tuple encoding for efficient state hashing
  • Handling of coin collection and removal from board
  • Time and space complexity analysis, and potential optimizations

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.