Practice Cat and Mouse II
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Cat and Mouse II
Problem Statement
The grid contains one C (Cat), one M (Mouse), one F (food), . floor cells and # walls. Mouse moves first, then turns alternate. On a turn, a player may stay still or move in a straight cardinal direction by any positive distance up to its jump limit, without crossing walls or leaving the grid. Mouse may jump over Cat. Cat wins by reaching Mouse, reaching food first, or preventing Mouse from reaching food within 1000 turns. Mouse wins by reaching food first. Return whether Mouse can force a win under optimal play. The maximum jump distances are catJump for Cat and mouseJump for Mouse.
Source: Cat and Mouse II on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
grid = ["####F","#C...","M...."], catJump = 1, mouseJump = 2
true
# Example 2
grid = ["M.C...F"], catJump = 1, mouseJump = 4
true
# Example 3
grid = ["M.C...F"], catJump = 1, mouseJump = 3
false
Constraints
Related LeetCode Problems
Practice more problems similar to Cat and Mouse II.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.