Snapchat logo

Snapchat Hard Interview Questions

3 hard-level practice questions for Snapchat technical interviews

Snapchat software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
coding Hard Verified Question #1

1. Expression Calculator


Category: String coding problem
Implement a calculator that evaluates a mathematical expression given as a string s. The expression may contain positive and negative integers, the...
Input: String
Output: Computed result
Want to practise this one?
Create a free account to open the full question and practise Snapchat questions with AI.
Sign up free
coding Hard Verified Question #2

2. Prime Subset Products


Category: Array coding problem
Given an array primes where every element is a prime number (duplicates are allowed), find all distinct products that can be formed by multiplying...
Input: Array
Output: Computed result
coding Hard graph #1

1. [Graph] — Find the nearest K restaurants with a limited barrier-crossing budget


Background
Snap Map supports discovering nearby places, including restaurants. For this interview exercise, model its walking-distance search using a grid with temporary barriers and a configurable crossing budget; this is a simplified model, not a claim about Snap Map's production routing implementation.
Problem statement
You are given a rectangular grid whose cells contain . for an ordinary walkable cell, # for a barrier, or R for a restaurant. Starting at start, you may move one cell up, down, left, or right. Every move costs one unit of walking distance.
A route may enter at most budget barrier cells. Each move into a # cell consumes one unit of that route's budget, including repeated entries into the same barrier. Moving out of a barrier into a non-barrier cell consumes no budget. The budget applies independently to each candidate route: you are finding nearby destinations, not planning one trip that visits every restaurant.
Return up to k reachable restaurants as records with integer fields row, col, and distance. A restaurant's distance is the minimum number of moves among all routes that respect the budget. Return each restaurant only once, ordered by distance ascending, then row ascending, then column ascending. If the starting cell is a restaurant, its distance is zero. Restaurants may be traversed like ordinary walkable cells.
Your implementation must avoid enumerating individual routes. In particular, explain why marking a grid coordinate as visited without considering the remaining crossing budget can produce an incorrect answer.
Function or class signature
  • nearest_restaurants(grid: list[str], start: tuple[int, int], k: int, budget: int) -> list[dict[str, int]]


Example 1:
Input:
{"grid":[".R#R.",".###.","R...R"],"start":[0,0],"k":3,"budget":1}
Output:
[{"row":0,"col":1,"distance":1},{"row":2,"col":0,"distance":2},{"row":0,"col":3,"distance":3}]
Explanation: The first two restaurants require no barrier crossings. The route (0,0) → (0,1) → (0,2) → (0,3) reaches the third restaurant in three moves and enters one barrier. The restaurant at (2,4) is reachable in six moves but is outside the nearest three.
Example 2:
Input:
{"grid":["R#R","###","R.R"],"start":[0,0],"k":5,"budget":0}
Output:
[{"row":0,"col":0,"distance":0}]
Explanation: The starting restaurant is included. Both adjacent cells are barriers, so no other restaurant is reachable without crossing a barrier.
Constraints:
  • 1 <= rows, cols <= 200 and rows * cols <= 40000.

  • Every row has the same length; every cell is ., #, or R.

  • start is an in-bounds coordinate containing . or R.

  • 0 <= budget <= 30.

  • 0 <= k <= rows * cols; return an empty list when k == 0.

  • Inputs are valid and must not be modified.


Follow-up:
Can you stop the traversal before exploring every reachable state once enough restaurants have been found? Explain exactly which distance layer must be completed to preserve the row-and-column tie-break, and how that changes the implementation.
Want to practise this one?
Create a free account to open the full question and practise Snapchat questions with AI.
Sign up free

Start practicing Snapchat questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free