1730. Shortest Path to Get Food
Last updated
Last updated
**Input:** grid = [["X","X","X","X","X","X"],["X","*","O","O","O","X"],["X","O","O","#","O","X"],["X","X","X","X","X","X"]]
**Output:** 3
**Explanation:** It takes 3 steps to reach the food.**Input:** grid = [["X","X","X","X","X"],["X","*","X","O","X"],["X","O","X","#","X"],["X","X","X","X","X"]]
**Output:** -1
**Explanation:** It is not possible to reach the food.**Input:** grid = [["X","X","X","X","X","X","X","X"],["X","*","O","X","O","#","O","X"],["X","O","O","X","O","O","X","X"],["X","O","O","O","O","#","O","X"],["X","X","X","X","X","X","X","X"]]
**Output:** 6
**Explanation:** There can be multiple food cells. It only takes 6 steps to reach the bottom food.**Input:** grid = [["O","*"],["#","O"]]
**Output:** 2**Input:** grid = [["X","*"],["#","X"]]
**Output:** -1