PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Snapchat

Determine escape path with blockers and spreading fire

Last updated: Mar 29, 2026

Quick Overview

This question evaluates graph traversal and grid-based pathfinding skills, including connectivity analysis, obstacle handling, and reasoning about time-dependent spreading processes.

  • hard
  • Snapchat
  • Coding & Algorithms
  • Software Engineer

Determine escape path with blockers and spreading fire

Company: Snapchat

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given a 2D grid representing a grassland. - Each cell is one of: - `S`: start - `T`: target - `.`: free cell - `#`: blocked cell (cannot enter) - `F`: initial fire source (for Part C) - You can move 4-directionally (up/down/left/right) to adjacent cells. ### Part A: Reachability Given the grid with `#` blockers (no fire yet), determine whether there exists **any path** from `S` to `T`. ### Part B: After adding a blocker Now suppose one additional free cell is turned into a blocker `#` (you are given its coordinates). Determine whether `S` can still reach `T` after this change. ### Part C: Maximum waiting time with spreading fire Now consider fire spread in the grid: - At time `0`, all `F` cells are on fire. - Each minute, fire spreads from burning cells to their 4-directional neighbors that are not blockers `#`. - You start at `S`. You may **wait** at `S` for `w` minutes (where `w ≥ 0` is an integer), then start moving 1 cell per minute. - You cannot enter or stay in a cell that is on fire **at or before** the time you arrive. - Reaching `T` is allowed only if you arrive before it burns (state the rule explicitly in your solution, e.g., “arrive strictly before it burns”). Compute the **maximum** waiting time `w` such that you can still reach `T` safely. If it is impossible even with `w = 0`, return `-1`. If you can wait arbitrarily long (never blocked by fire), return a large sentinel value (e.g., `10^9`). ### Input/Output (for all parts) - Input: `grid` as an `m x n` array of characters; for Part B, also `(r, c)` coordinates to block. - Output: - Part A/B: boolean - Part C: integer maximum `w` ### Constraints (reasonable interview constraints) - `1 ≤ m, n ≤ 300` (or similar) - Grid contains exactly one `S` and one `T`. - Multiple `F` possible (Part C).

Quick Answer: This question evaluates graph traversal and grid-based pathfinding skills, including connectivity analysis, obstacle handling, and reasoning about time-dependent spreading processes.

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
Feb 11, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
1
0
Loading...

You are given a 2D grid representing a grassland.

  • Each cell is one of:
    • S : start
    • T : target
    • . : free cell
    • # : blocked cell (cannot enter)
    • F : initial fire source (for Part C)
  • You can move 4-directionally (up/down/left/right) to adjacent cells.

Part A: Reachability

Given the grid with # blockers (no fire yet), determine whether there exists any path from S to T.

Part B: After adding a blocker

Now suppose one additional free cell is turned into a blocker # (you are given its coordinates). Determine whether S can still reach T after this change.

Part C: Maximum waiting time with spreading fire

Now consider fire spread in the grid:

  • At time 0 , all F cells are on fire.
  • Each minute, fire spreads from burning cells to their 4-directional neighbors that are not blockers # .
  • You start at S . You may wait at S for w minutes (where w ≥ 0 is an integer), then start moving 1 cell per minute.
  • You cannot enter or stay in a cell that is on fire at or before the time you arrive.
  • Reaching T is allowed only if you arrive before it burns (state the rule explicitly in your solution, e.g., “arrive strictly before it burns”).

Compute the maximum waiting time w such that you can still reach T safely. If it is impossible even with w = 0, return -1. If you can wait arbitrarily long (never blocked by fire), return a large sentinel value (e.g., 10^9).

Input/Output (for all parts)

  • Input: grid as an m x n array of characters; for Part B, also (r, c) coordinates to block.
  • Output:
    • Part A/B: boolean
    • Part C: integer maximum w

Constraints (reasonable interview constraints)

  • 1 ≤ m, n ≤ 300 (or similar)
  • Grid contains exactly one S and one T .
  • Multiple F possible (Part C).

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.