Find shortest path in a maze grid
Company: Meta
Role: Machine Learning Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Quick Answer: This question evaluates proficiency in graph traversal and shortest-path reasoning on grid-based data structures, testing skills in pathfinding, state-space modeling, and algorithmic complexity 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,1],[0,0,0],[1,0,0]], (0,0), (2,2))
Expected Output: 4
Explanation: Reachable maze.
Input: ([[0,1],[1,0]], (0,0), (1,1))
Expected Output: -1
Explanation: Unreachable.
Input: ([[0]], (0,0), (0,0))
Expected Output: 0
Explanation: Same cell.
Hints
- Choose a representation that makes the core operation simple.
- Handle empty and boundary inputs before the main algorithm.