PracHub
QuestionsPremiumLearningGuidesInterview PrepCoaches
|Home/Coding & Algorithms/Snapchat

Find Shortest Clear Grid Path

Last updated: Apr 2, 2026

Quick Overview

This question evaluates a candidate's competency in grid-based shortest-path and graph traversal concepts, including modeling a 2D binary grid, handling obstacles, and reasoning about multi-directional neighbor movement.

  • medium
  • Snapchat
  • Coding & Algorithms
  • Machine Learning Engineer

Find Shortest Clear Grid Path

Company: Snapchat

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Given an `n x n` binary grid, where `0` means open and `1` means blocked, return the length of the shortest path from the top-left cell to the bottom-right cell. You may move in all 8 directions to neighboring cells. A valid path may only pass through open cells. If either endpoint is blocked or no path exists, return `-1`.

Quick Answer: This question evaluates a candidate's competency in grid-based shortest-path and graph traversal concepts, including modeling a 2D binary grid, handling obstacles, and reasoning about multi-directional neighbor movement.

Related Interview Questions

  • Determine Whether Courses Can Be Completed - Snapchat (medium)
  • Solve Decimal Coin Change - Snapchat (medium)
  • Find Maximum Island Perimeter - Snapchat (medium)
  • Solve Three Algorithmic Tasks - Snapchat (hard)
  • Implement a Timestamped Counter - Snapchat (medium)
Snapchat logo
Snapchat
Jun 28, 2025, 12:00 AM
Machine Learning Engineer
Onsite
Coding & Algorithms
2
0

Given an n x n binary grid, where 0 means open and 1 means blocked, return the length of the shortest path from the top-left cell to the bottom-right cell. You may move in all 8 directions to neighboring cells. A valid path may only pass through open cells. If either endpoint is blocked or no path exists, return -1.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Snapchat•More Machine Learning Engineer•Snapchat Machine Learning Engineer•Snapchat Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,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.