A game on an undirected graph is played by two players, Mouse and Cat, who alternate turns.
The graph is given as follows:
graph[a] is a list of all nodes
b such that
ab is an edge of the graph.
The mouse starts at node
1 and goes first, the cat starts at node
2 and goes second, and there is a hole at node
During each player's turn, they must travel along one edge of the graph that meets where they are. For example, if the Mouse is at node 1, it must travel to any node in
Additionally, it is not allowed for the Cat to travel to the Hole (node 0.)
Then, the game can end in three ways:
graph, and assuming both players play optimally, return
1if the mouse wins the game,
2if the cat wins the game, or
0if the game is a draw.
Input: graph = [[2,5],,[0,4,5],[1,4,5],[2,3],[0,2,3]] Output: 0
Input: graph = [[1,3],,,[0,2]] Output: 1
3 <= graph.length <= 50
1 <= graph[i].length < graph.length
0 <= graph[i][j] < graph.length
graph[i][j] != i