End of Year Sale: Use Coupon Code END2025 to Get Extra 25% Off.
06DAYS
:
17HOURS
:
12MINUTES
:
38SECONDS
Leetcode Problem 913. Cat and Mouse
913. Cat and Mouse
Leetcode Solutions
Minimax Algorithm with Percolation from Resolved States
Initialize color, a map of states to their outcome (MOUSE, CAT, DRAW).
Initialize a queue and add all initially resolved states to it.
While the queue is not empty:
a. Dequeue a state.
b. For each parent state of the dequeued state:
i. If immediate coloring is possible, color the parent state.
ii. If not, decrement the count of DRAW children.
iii. If the count of DRAW children is zero, apply eventual coloring.
c. Enqueue any newly colored parent states.
After processing all states, return the color of the initial state (1, 2, 1).