PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Snapchat

Compute minimum escape time in a grid

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's competence in graph traversal, shortest-path computation, and reachability analysis on grid-based representations.

  • medium
  • Snapchat
  • Coding & Algorithms
  • Software Engineer

Compute minimum escape time in a grid

Company: Snapchat

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are given a 2D floor plan grid. Each cell is one of: - `.` empty space (walkable) - `#` wall/blocked (not walkable) - `P` a person - `E` an exit A person can move 1 step per minute to the 4-neighbors (up/down/left/right) through walkable cells. Multiple people can occupy the same cell at the same time (ignore collisions). Task: 1) Determine whether **every** person can reach **some** exit. 2) If everyone can escape, return the **minimum time until all people have escaped**, assuming each person walks optimally (i.e., the maximum over people of their shortest-path distance to any exit). If some person cannot reach any exit, return `-1`. Explain an algorithm and its time/space complexity.

Quick Answer: This question evaluates a candidate's competence in graph traversal, shortest-path computation, and reachability analysis on grid-based representations.

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
Jan 26, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
4
0

You are given a 2D floor plan grid. Each cell is one of:

  • . empty space (walkable)
  • # wall/blocked (not walkable)
  • P a person
  • E an exit

A person can move 1 step per minute to the 4-neighbors (up/down/left/right) through walkable cells. Multiple people can occupy the same cell at the same time (ignore collisions).

Task:

  1. Determine whether every person can reach some exit.
  2. If everyone can escape, return the minimum time until all people have escaped , assuming each person walks optimally (i.e., the maximum over people of their shortest-path distance to any exit).

If some person cannot reach any exit, return -1.

Explain an algorithm and its time/space complexity.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Snapchat•More Software Engineer•Snapchat Software Engineer•Snapchat Coding & Algorithms•Software 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.