The Cat and Mouse interview question is a complex graph-based game. A Mouse and a Cat are on a graph. The Mouse starts at node 1, the Cat at node 2, and node 0 is the "Hole." Players take turns moving to adjacent nodes. The Mouse wins if it reaches the Hole. The Cat wins if it catches the Mouse (same node). If the game continues indefinitely, it's a Draw. This Cat and Mouse coding problem is a pinnacle of game theory simulation.
This HARD problem is used by Google and Microsoft to test for extreme proficiency in dynamic programming and graph theory. It requires the Minimax algorithm or Topological Sort on game states. It tests how you handle "Draws" (cycles in the game graph), which is much harder than simple win/loss scenarios.
This utilizes the Math, Graph, Memoization, Topological Sort, Game Theory, Dynamic Programming interview pattern.
Graph: 0-1, 1-2, 2-0 (A triangle)
For game problems with cycles, think about "retrograde analysis." Start from the end (the result) and work your way back to the starting positions. This is often more reliable than forward-searching with DFS.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Cat and Mouse II | Hard | Solve | |
| Flip Game II | Medium | Solve | |
| Count Visited Nodes in a Directed Graph | Hard | Solve | |
| Largest Color Value in a Directed Graph | Hard | Solve | |
| Stone Game IV | Hard | Solve |