Search
⌘K

Leetcode 913. Cat and Mouse

Two players alternate moves along edges of an undirected graph: the mouse starts at 1, the cat at 2 (cat cannot enter node 0), and the game ends if the mouse reaches hole 0 (mouse wins), the cat lands on the mouse (cat wins), or a position repeats (draw). Determine which of the three outcomes occurs under optimal play — essentially resolving a finite game-state graph (mouse, cat, turn) with cycles/draws via retrograde analysis/BFS.

Asked at:

Google

Google


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Early January, 2026

Google

Google

Staff

No constraints were added, could be any shape. A lot of focus on test cases.

Late December, 2024

Google

Google

Mid-level

Cat and Mouse game

Comments

Your account is free and you can post anonymously if you choose.