Solve grid shortest path with BFS
Company: Disney
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Onsite
Quick Answer: This question evaluates understanding of grid traversal and shortest-path graph search, including modeling a 2D grid with obstacles and reasoning about boundary and edge cases, within the Coding & Algorithms domain.
Constraints
- Inputs are provided as Python literals matching the function signature.
- Return a deterministic exact-match result.
Examples
Input: ([[0,0,0],[1,1,0],[0,0,0]], (0,0), (2,2))
Expected Output: 4
Explanation: Path around walls.
Input: ([[0,1],[1,0]], (0,0), (1,1))
Expected Output: -1
Explanation: Blocked target.
Input: ([[0]], (0,0), (0,0))
Expected Output: 0
Explanation: Start equals target.
Hints
- Choose a representation that makes the core operation simple.
- Handle empty and boundary inputs before the main algorithm.