PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Disney

Implement BFS shortest path in grid

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of graph traversal and pathfinding concepts, particularly breadth-first search on unweighted 2D grids, along with algorithmic complexity analysis and edge-case handling in the Coding & Algorithms domain.

  • Medium
  • Disney
  • Coding & Algorithms
  • Software Engineer

Implement BFS shortest path in grid

Company: Disney

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Implement a function that returns the length of the shortest path in an unweighted 2D grid from the top-left cell (0, 0) to the bottom-right cell (m-1,n- 1). The grid contains '0' for open cells and '1' for walls; movement is allowed only in four directions (up, down, left, right). If either the start or end is blocked, or no path exists, return -1. Provide the algorithm (BFS), explain why it is appropriate, analyze time and space complexity, and discuss edge cases such as single-cell grids, large grids (up to 10^5 cells), and multiple shortest paths. Optionally extend to support diagonal moves and explain the change needed.

Quick Answer: This question evaluates understanding of graph traversal and pathfinding concepts, particularly breadth-first search on unweighted 2D grids, along with algorithmic complexity analysis and edge-case handling in the Coding & Algorithms domain.

Related Interview Questions

  • Implement an LRU cache - Disney (medium)
  • Filter ads by a single rule - Disney (medium)
  • Determine if chasing points will meet - Disney (medium)
  • Solve matrix add, frequency count, longest consecutive - Disney (Medium)
  • Solve grid shortest path with BFS - Disney (Medium)
Disney logo
Disney
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
3
0

Implement a function that returns the length of the shortest path in an unweighted 2D grid from the top-left cell (0, 0) to the bottom-right cell (m-1,n- 1). The grid contains '0' for open cells and '1' for walls; movement is allowed only in four directions (up, down, left, right). If either the start or end is blocked, or no path exists, return -1. Provide the algorithm (BFS), explain why it is appropriate, analyze time and space complexity, and discuss edge cases such as single-cell grids, large grids (up to 10^5 cells), and multiple shortest paths. Optionally extend to support diagonal moves and explain the change needed.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Disney•More Software Engineer•Disney Software Engineer•Disney Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.