< Previous
Next >
[Breadth-First Search]
[Array]
[Matrix]
Hint 1
Run BFS starting from the '*' position.
Hint 2
Keep the current number of the steps as a state in the queue.
Hint 3
The first time you reach a food, return the number of steps as the answer.
Hint 4
In case the queue is empty and you still did not manage to reach a food, return -1.