Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions