← Snapchat Interview Insights

Snapchat·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Snapchat SWE interview with a grid-based pathfinding problem. The core challenge was figuring out the right BFS direction, which tripped me up a bit before clicking into place.

Questions Asked (1)

Q1

Given a 2D grid floor plan with people, exits, empty cells, and blockers, determine if all people can escape to an exit and return the minimum time for everyone to escape. People move one cell per step in 4 directions, moves are simultaneous, and blockers cannot be crossed.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

My first instinct was BFS from each person separately, which technically works but is way slower than it needs to be.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a multi-source BFS from all exits simultaneously, computing the shortest distance from each cell to the nearest exit. Then, the minimum time for all people to escape is the maximum of these distances across all people; if any person cannot reach an exit, return -1.

Pro tip: Clarify upfront that people can share cells and exits without capacity limits, as this simplifies the problem to independent shortest paths. Also, mention that if exits had capacity constraints, the problem would become a flow or matching problem, showing awareness of trade-offs.

1. Clarify assumptions and constraints

Confirm that people can occupy the same cell and that exits have unlimited capacity. Also, verify that blockers are static and that people move simultaneously without interfering.

2. Model as graph problem

Treat each cell as a node with edges to its 4-directional neighbors if they are not blockers. Exits are target nodes, and people are sources.

3. Compute distances via multi-source BFS

Initialize a queue with all exit cells at distance 0. Perform BFS to compute the shortest distance from every reachable cell to the nearest exit.

4. Determine escape time and feasibility

For each person, check if their distance is defined (reachable). If any person is unreachable, return -1. Otherwise, the answer is the maximum distance among all people.

5. Analyze complexity and edge cases

Discuss time and space complexity (O(R*C)), and consider edge cases like no people, no exits, or people already at exits.

Key Points to Mention

  • Multi-source BFS from all exits to compute shortest distances efficiently.
  • Simultaneous movement means the total time is the maximum of individual shortest path lengths.
  • Blockers are obstacles; BFS naturally avoids them.
  • If any person cannot reach an exit, return -1.
  • Time complexity O(R*C) and space complexity O(R*C) for the grid and queue.
  • Edge cases: no people (return 0), no exits (return -1), people already at exits (distance 0).

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.