← Snapchat Interview Insights

Snapchat·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Snapchat software engineer interview with a mix of classic LeetCode problems spanning math, graph traversal, data structures, and streaming algorithms. Nothing too exotic but the range was wide enough to keep you on your toes.

Questions Asked (4)

Q1

Given a deck of cards represented as integers, determine whether you can split the deck into groups of X cards where every group has the same number.

Algorithms & Data Structures
Author's notes

The GCD angle took me a minute to see.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify that the deck is represented as an array of integers where each integer denotes a card value. Then, count the frequency of each card value and determine if there exists a group size X (X >= 2) such that every frequency is divisible by X. The key is to compute the greatest common divisor (GCD) of all frequencies and check if it is at least 2.

Pro tip: Mention edge cases like empty deck or single card early, and note that X must be at least 2. Also, discuss that if the GCD is 1, no valid X exists, and if the GCD is >=2, any divisor of the GCD (including the GCD itself) works.

1. Clarify the problem

Confirm that the deck is an array of integers, and we need to partition it into groups of size X (X >= 2) where all cards in each group have the same number. Ask if X is given or if we need to find if any X exists.

2. Count frequencies

Use a hash map to count the occurrence of each card value. This gives the frequency of each distinct number in the deck.

3. Compute GCD of frequencies

Calculate the greatest common divisor (GCD) of all frequency counts. This represents the largest possible group size that can evenly divide all frequencies.

4. Check validity

If the GCD is at least 2, then it is possible to split the deck into groups of size X (e.g., X = GCD). If the GCD is 1, no such X >= 2 exists, so return false.

5. Discuss complexity and edge cases

Analyze time complexity O(N) where N is the number of cards, and space complexity O(K) where K is the number of distinct card values. Mention edge cases: empty deck, single card, all cards same, etc.

Key Points to Mention

  • Frequency counting using a hash map
  • Greatest common divisor (GCD) of frequencies
  • Condition that GCD must be >= 2
  • Time and space complexity analysis
  • Edge cases: empty deck, single card, all cards identical
  • Alternative approach: check if any X from 2 to min frequency divides all frequencies

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

Q2

Given a 2D grid with islands, count the number of distinct island shapes where two islands are considered the same if one can be translated to match the other.

Algorithms & Data Structures
Author's notes

This one tripped me up a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use DFS/BFS to traverse each island, recording the relative coordinates of its cells. Normalize each island's shape by translating it so its top-leftmost cell is at (0,0), then store the normalized shape in a set to count distinct shapes.

Pro tip: Clarify whether rotations or reflections count as the same shape; the problem states only translation, so avoid overcomplicating. Also, mention that using a set of tuples (or a string representation) ensures efficient duplicate detection.

1. Clarify the problem

Confirm that only translation is allowed, not rotation or reflection. Discuss grid size and constraints to choose appropriate algorithms.

2. Traverse islands

Iterate through each cell; when an unvisited land cell is found, perform DFS/BFS to collect all connected land cells, marking them visited.

3. Normalize shape

For each island, compute the minimum row and column among its cells. Subtract these from each cell's coordinates to translate the shape to the origin.

4. Store and count distinct shapes

Insert the normalized set of coordinates (e.g., as a sorted tuple of tuples) into a hash set. The size of the set is the number of distinct shapes.

5. Analyze complexity

State that time complexity is O(R*C) for traversal and normalization, and space complexity is O(R*C) for visited and shape storage.

Key Points to Mention

  • DFS/BFS for island traversal
  • Relative coordinate representation
  • Normalization by translation (subtracting min row/col)
  • Using a hash set for distinct shapes
  • Time and space complexity analysis
  • Handling edge cases (empty grid, no islands, single cell)

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

Q3

Implement a Trie data structure that supports inserting words, searching for exact words, and checking if any word starts with a given prefix.

Algorithms & Data StructuresSystem Design
Author's notes

Pretty standard, just implement it clean.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, then design a TrieNode class with a children map and an isEndOfWord flag. Implement insert, search, and startsWith methods iteratively, and analyze time and space complexity.

Pro tip: Mention that using a hash map for children makes the Trie more flexible for arbitrary characters, but an array of size 26 is more memory-efficient for lowercase English letters. Also, discuss how the Trie can be extended to support features like autocomplete or wildcard search.

1. Clarify requirements and constraints

Ask about the character set (e.g., lowercase English letters), expected operations, and any memory constraints. Confirm whether words can be empty or contain special characters.

2. Design the TrieNode structure

Define a TrieNode with a children data structure (e.g., hash map or array) and a boolean flag isEndOfWord. Explain the trade-offs between different implementations.

3. Implement insert, search, and startsWith

Write iterative methods that traverse the Trie, creating nodes as needed for insert, and checking for node existence for search and startsWith. Ensure search checks the isEndOfWord flag.

4. Analyze complexity and edge cases

Discuss time complexity O(m) for each operation where m is the word length, and space complexity O(n*m) for n words. Handle edge cases like empty strings and null inputs.

5. Discuss extensions and optimizations

Mention potential extensions like autocomplete, wildcard search, or memory optimizations such as using a compressed Trie (radix tree).

Key Points to Mention

  • TrieNode structure with children and isEndOfWord flag
  • Time complexity O(m) per operation, space complexity O(n*m)
  • Choice of children data structure: hash map vs array
  • Handling edge cases: empty string, null, and non-alphabetic characters
  • Comparison with hash table: prefix search efficiency
  • Potential extensions: autocomplete, wildcard search, compressed Trie

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

Q4

Design a data structure that supports adding numbers from a stream and querying the median at any point in time.

Algorithms & Data StructuresSystem Design
Author's notes

Two heaps, max-heap for the lower half and min-heap for the upper half.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use two heaps (a max-heap for the lower half and a min-heap for the upper half) to maintain the median in O(log n) insertion and O(1) query. Explain the balancing invariant and how to handle even/odd total counts. Discuss trade-offs with alternative approaches like a self-balancing BST or sorted list.

Pro tip: Proactively discuss how to handle duplicate values and potential integer overflow when computing the median of two middle elements. Also, mention that this design is used in real-time analytics at Snapchat for metrics like median view time.

1. Clarify requirements and constraints

Ask about the expected volume of numbers, whether the stream is infinite, and if memory is a concern. Confirm that median queries will be frequent and interleaved with insertions.

2. Propose a two-heap approach

Describe maintaining a max-heap for the smaller half and a min-heap for the larger half. Explain that the median is either the top of the max-heap (odd count) or the average of both tops (even count).

3. Detail the insertion algorithm

Outline the steps: add to max-heap, move the largest to min-heap, then rebalance if sizes differ by more than one. Emphasize maintaining the invariant that max-heap size is either equal to or one greater than min-heap size.

4. Analyze complexity and edge cases

State that insertion is O(log n) and median query is O(1). Discuss edge cases: empty stream, single element, duplicates, and negative numbers.

5. Compare with alternatives and discuss scalability

Mention other approaches like a self-balancing BST (O(log n) insert, O(log n) query) or a sorted list (O(n) insert). Highlight that the two-heap solution is optimal for this use case and can be extended to sliding windows.

Key Points to Mention

  • Two-heap data structure with max-heap for lower half and min-heap for upper half
  • Balancing invariant: max-heap size is either equal to or one greater than min-heap size
  • O(log n) insertion time and O(1) median query time
  • Handling even and odd total counts for median calculation
  • Edge cases: empty stream, duplicates, negative numbers, and integer overflow
  • Trade-offs with alternative approaches like self-balancing BST or sorted list

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