The "Cat and Mouse II interview question" is a complex game-theory challenge set on a 2D grid. Unlike its predecessor, this version introduces specific jump distances for both the cat and the mouse. The mouse aims to reach a "food" cell or survive for a specific number of turns, while the cat tries to catch the mouse or prevent it from reaching the food. The grid contains walls that neither can pass through. This "Cat and Mouse II coding problem" requires determining if the mouse can win given optimal play from both sides.
Google frequently asks the "Cat and Mouse II coding problem" because it tests multiple advanced computer science concepts in a single scenario. It evaluates a candidate's mastery of graph traversal, game theory (specifically minimax or state-based transitions), and dynamic programming with memoization. It also challenges your ability to handle complex state spaces where the "winner" depends on perfect play from both opponents.
This problem utilizes the Game Theory interview pattern combined with Dynamic Programming (DP) and Memoization.
Imagine a grid where the mouse is at (0,0), the cat is at (2,2), and food is at (0,2). If the mouse has a jump power of 2, it can reach the food in its first turn if no walls are in the way. However, if the cat has a jump power of 5, it can intercept the mouse at almost any cell. The "Array interview pattern" comes into play when calculating reachable indices within the jump constraints while checking for walls.
Practice "Game Theory" problems where two players interact. Learn how to transform a game into a state-transition graph. Understanding how to use memoization to store "Win", "Loss", or "Draw" for a given (mouse_pos, cat_pos, turn) is key to solving hard-level grid games.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Cat and Mouse | Hard | Solve | |
| Longest Increasing Path in a Matrix | Hard | Solve | |
| Number of Increasing Paths in a Grid | Hard | Solve | |
| Stone Game V | Hard | Solve | |
| Build a Matrix With Conditions | Hard | Solve |