Question: Given a n * n grid where each cell has one of three values : 0 represents an empty cell 1 represents there is a

Given a n*n grid where each cell has one of three values :
0 represents an empty cell
1 represents there is a cheese in the cell
2 represents there is a rat in the cell.
Now the rat has a special ability that he can clone himself four times and go upward(i-1, j), right(i, j+1), down(i+1, j), left(i, j-1). The rat will only go to the given directions if a cheese is in there in the cell he can go all for directions and eat in 1 second.
Find the minimum time he needs to eat all Cheese available in the grid.
If it is impossible to eat all the cheese then return -1.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!