Snapchat logo

Snapchat Interview Questions

14 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 Medium Verified Question #1

1. Largest Island Perimeter


Category: Grid/matrix coding problem
You are given an m x n binary grid where each cell is either '1' (land) or '0' (water). A group of connected land cells (connected horizontally...
Input: 2D grid
Output: Computed result
coding Medium Verified Question #2

2. Parallel Task Batching


Category: Graph coding problem
A pipeline must execute a set of tasks with dependency constraints. Each dependency [A, B] means task A must complete before task B can start....
Input: Graph (nodes and edges)
Output: Computed result
coding Medium Verified Question #3

3. Island Statistics


Category: Grid/matrix coding problem
You are given an m x n binary grid where '1' is land and '0' is water. For each island (a connected group of land cells using horizontal and...
Input: 2D grid
Output: Array
coding Medium Verified Question #4

4. Unfriended Pairs Counter


Category: Algorithm coding problem
In a social network of n people labeled 0 to n - 1, friendship is mutual and transitive through direct connections. People belong to the same...
Input: List
Output: Computed result
coding Hard Verified Question #5

5. 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
coding Hard Verified Question #6

6. 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 Medium Verified Question #7

7. Peak Attendance Finder


Category: Interval-based coding problem
You are organizing an event. Each attendee's presence is described by a half-open interval [entry, exit), meaning they are present at every integer...
Input: List
Output: Integer
coding Medium Verified Question #8

8. Org Chart Builder


Category: String coding problem
A company has a list of employees. Each entry has three strings: [id, manager_id, name]. The CEO is the only employee whose manager_id equals...
Input: List
Output: Computed result
coding Medium binary search #1

1. Binary Search — Find a User by Username

1. Background: In Snapchat, users often search for friends by their username. Efficiently locating users in a vast database is crucial to provide a smooth user experience and maintain engagement.
2. Problem statement: Given a sorted list of unique usernames and a target username, return the index of the target username in the list. If the username does not exist, return -1. Implement a function using binary search to optimize the search efficiency.
3. Function signature: def find_username(usernames: List[str], target: str) -> int
4. Example 1:
Input: usernames = ['alice', 'bob', 'charlie', 'dave'],
target = 'charlie'
Output: 2
Explanation: The username 'charlie' is found at index 2.
5. Example 2:
Input: usernames = ['alice', 'bob', 'charlie', 'dave'],
target = 'eve'
Output: -1
Explanation: The username 'eve' is not in the list.
6. Constraints:
- 1 <= len(usernames) <= 10^4
- Each username has at most 100 characters, containing only lowercase letters and numbers.
coding Medium hash map #2

2. [Hash Map] — Implement a user status checker for Snapchat

Background: Snapchat frequently updates user statuses, which can be seen by friends. Implementing a system to efficiently check the status of multiple users is essential to enhance user engagement and ensure the app runs smoothly.
Problem statement: You need to design a function that takes a list of user IDs and returns their current status from a predefined mapping of user statuses. The function should handle requests efficiently, especially when the same user ID is checked multiple times. Specifically, if the user ID does not exist in the mapping, return "unknown".
Function/class signature:
  • def check_user_status(user_ids: List[str], user_status: Dict[str, str]) -> List[str]:

Example 1:
  • Input: user_ids = ["user1", "user2", "user3"], user_status = {"user1": "active", "user2": "inactive"}

  • Output: ['active', 'inactive', 'unknown']

  • Explanation: user1 is active, user2 is inactive, and user3 has no status set.

Example 2:
  • Input: user_ids = ["user3", "user4"], user_status = {"user4": "active"}

  • Output: ['unknown', 'active']

  • Explanation: user3 is not in the mapping, while user4 is active.

Constraints:
  • 1 <= len(user_ids) <= 10^4

  • 1 <= len(user_status) <= 10^4

  • User IDs consist of alphanumeric characters and underscores only.

  • If a user ID is checked multiple times, you can expect the check to be performed efficiently.
coding Medium graph #3

3. [Graph] — Implement a Friend Suggestion Algorithm

Background: In Snapchat, users send snaps to friends, and often inquire about friends-of-friends to expand their network. A key feature is suggesting new friends based on existing connections.
Problem statement: Given a list of users and their friend connections, implement a function that returns a list of suggested friends for a given user. Friend suggestion examines friends-of-friends and excludes those already connected to the user. The result should prioritize suggestions by the number of mutual friends shared with the user.
Function/class signature:
  • def suggest_friends(user: str, connections: List[Tuple[str, str]]) -> List[str]:

Example 1:
  • Input: user = "Alice", connections = [("Alice", "Bob"), ("Alice", "Charlie"), ("Bob", "David"), ("Charlie", "David"), ("Bob", "Eve")]

  • Output: ['David', 'Eve']

  • Explanation: Alice shares mutual friends with David and Eve, making them suitable suggestions.

Example 2:
  • Input: user = "Bob", connections = [("Alice", "Bob"), ("Alice", "Charlie"), ("Bob", "David"), ("Charlie", "David"), ("Bob", "Eve")]

  • Output: ['Charlie', 'Eve']

  • Explanation: Bob has mutual connections with Charlie and Eve that are not his direct friends.

Constraints:
  • 1 ≤ number of connections ≤ 10^5

  • Each user name is at most 50 characters long

  • Connections are undirected; each pair (a, b) implies both a is a friend of b and vice versa.
coding Medium two pointers #4

4. [Two Pointers] — Finding the Optimal Snap Filters

Background: Snapchat uses a variety of filters to enhance user engagement. To suggest optimal filters based on user preferences and photo characteristics, a two-pointer approach can help identify compatible filters quickly.
Problem statement: You are given two sorted lists of filters and user preferences. Each filter has a rating and each user preference specifies a desired rating range. Your task is to find the maximum number of filters that fit within the user's desired ratings while ensuring each filter is only used once. Return the total count of usable filters.
Function/class signature:
  • def max_snap_filters(filters: List[int], preferences: List[Tuple[int, int]]) -> int:


Example 1:
  • Input: filters = [1, 3, 5, 7], preferences = [(2, 5), (3, 7)]

  • Output: 3

  • Explanation: Filters {3, 5, 3} can be used for the preferences.


Example 2:
  • Input: filters = [2, 4, 6], preferences = [(1, 3), (4, 5)]

  • Output: 1

  • Explanation: Only filter {4} can be used for the second preference.


Constraints:
  • Filters list length: 1 <= len(filters) <= 100000

  • Preferences list length: 1 <= len(preferences) <= 10000

  • Filter ratings: 0 <= filters[i] <= 100

  • Preference ranges: 0 <= preferences[i][0] <= preferences[i][1] <= 100
coding Medium graph #5

5. Graph Traversal — Finding Users in a Snapchat Group

Background: Snapchat allows users to create groups where they can interact with multiple friends at once. For features like notifications or updates, it's important to quickly identify users in a group. This problem relates to the social graph architecture used by Snapchat to model users and connections.
Problem statement: Given a list of users represented as a graph where each user is a node and friendships are edges, write a function that finds all user IDs in a group by performing a breadth-first search (BFS) starting from a given user ID. The function should return the user IDs of all reachable friends within k steps.
Function/class signature:
  • def find_users_in_group(graph: Dict[int, List[int]], start_user: int, k: int) -> List[int]:


Example 1:
Input: graph = {1: [2, 3], 2: [1, 4], 3: [1], 4: [2]}, start_user = 1, k = 2
Output: [1, 2, 3, 4]
Explanation: From user 1, within 2 steps, all users 2, 3, and 4 are reachable.
Example 2:
Input: graph = {1: [2], 2: [1, 3], 3: [2], 4: []}, start_user = 2, k = 1
Output: [2, 1, 3]
Explanation: From user 2, within 1 step, users 1 and 3 are reachable.
Constraints:
  • All user IDs are unique integers.

  • The graph may contain up to 10^5 users.

  • 0 <= k <= 10^5.

  • The graph is undirected and may contain cycles.
coding Medium sliding window #6

6. CODING — Longest Unique Substring Finder

1. Background: Snapchat frequently deals with media messaging, where users can send images, videos, and messages that often contain unique identifiers or metadata. An efficient way of allowing users to search through their messages is to keep track of unique content.
2. Problem statement: Given a string s, your goal is to find the length of the longest substring that does not contain any repeated characters. This challenge is critical for Snapchat as it could relate to efficiently managing and displaying unique identifiers in user-generated content across the platform.
3. Function/class signature:
- def longest_unique_substring(s: str) -> int:
4. Example 1:
- Input: "abcabcbb"
- Output: 3
- Explanation: The longest substring without repeating characters is "abc", which has length 3.
5. Example 2:
- Input: "bbbbb"
- Output: 1
- Explanation: The longest substring without repeating characters is "b", which has length 1.
6. Constraints:
- 0 <= s.length <= 1000
- s consists of English letters, digits, symbols, and spaces.

Start practicing Snapchat questions

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

Get Started Free