550. Shortest Path to Get Food

Medium
Array
Breadth-First Search
Matrix

Description

Hints

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.

Statistics

Acceptance
57.0%
Submissions
143,414
Accepted
81,780