Snapchat Software Engineer Coding & Algorithms Interview Questions
Master your tech interview with our curated database of real questions from top companies.
Determine blockage and parse HTML tokens
Question Given a set of 2-D circular stones, determine whether they can completely block the width of a river. You may define the input format. Given ...
Compute sliding window median
Question LeetCode 480. Sliding Window Median: Given an array nums and an integer k, find the median of each sliding window of size k as the window mov...
Handle cards, islands, Trie, median
Question LeetCode 914. X of a Kind in a Deck of Cards LeetCode 694. Number of Distinct Islands LeetCode 208. Implement Trie (Prefix Tree) LeetCode 295...
Compute longest increasing path in matrix
You are given an m x n grid (matrix) of integers grid, where m >= 1 and n >= 1. A path in the matrix is a sequence of cells where: - You may move from...
Count ways to decode digit string
You are given a string s consisting of digits '0' to '9'. The string encodes a message using the following mapping: - '1' → A, '2' → B, ..., '26' → Z....
Design Manhattan-distance meeting point finder
Given an m×n grid with cells marked 1 for homes and 0 otherwise, choose a single meeting cell that minimizes the sum of Manhattan distances from all h...
Solve a two-jug measuring problem
You are given two jugs with capacities x and y liters and an unlimited water source. You may perform these operations: fill a jug, empty a jug, or pou...
Find top co-purchased products
You receive purchase logs where each order is represented as an integer array of product IDs bought together in a single transaction. Implement a func...
Implement binary search for boundary index
Given a sorted integer array nums (length n) and an integer target t, return the index of the first element in nums that is greater than or equal to t...
Compute islands in a binary grid
You are given an m-by-n grid of characters where '1' represents land and '0' represents water. Count the number of connected land masses (islands) usi...
Count islands with eight-direction adjacency
You are given an m×n grid of characters '1' (land) and '0' (water). Count the number of islands, where cells are connected if they touch in any of the...
Implement XML tokenizer and parser with operations
You are given either (a) a raw XML-like string such as <catalog><book><author>Gambardella, Matthew</author></book></catalog> or (b) its tokenized form...
Solve Open the Lock BFS
Question LeetCode 752. Open the Lock – Given an initial lock state "0000", a target combination, and a list of deadend combinations that cannot be use...
Compute shortest recursive string encoding
Given a string s, compress it by replacing any consecutive repetition of a substring with the form k{pattern} where k > 1 and pattern may itself be re...
Solve rotating-lock BFS with blockers
You are given a 4-digit lock starting at "0000". In one move, you may pick a single position and rotate it +1 or −1 with wrap-around (0→9 on −1, 9→0 o...
Find index of first unique character
Given a string s, return the index of the first character that appears exactly once; if none exists, return -1. Assume s may include both lowercase an...