Snowflake Coding & Algorithms Interview Questions
Master your tech interview with our curated database of real questions from top companies.
Solve and optimize 3Sum and variants at scale
Implement a function that returns all unique triplets (i, j, k) of indices whose values sum to a target T, with strong performance and deduplication g...
Implement DFS with cycle detection and topo order
Implement DFS (recursive and iterative) with topo sort, cycle detection, and timestamps You are given a directed graph G with N nodes labeled 1..N and...
Check balanced parentheses with multiple bracket types
Given a string containing only parentheses '()', determine whether it is balanced. Follow-up: extend the solution to also support '[]' and '{}' with c...
Solve build ordering and expression evaluation
Part A — Dependency ordering: You are given an integer n (0 ≤ n ≤ 200000) representing tasks labeled 0..n-1 and a list of prerequisite pairs [a, b] me...
Filter hierarchical paths after deletions
Given two arrays: ( 1) paths — slash-delimited hierarchical strings such as "California", "California/San Francisco", "California/San Francisco/7th St...
Compute task order and layered execution
You have N tasks labeled 0..N-1 and prerequisite pairs (a, b) meaning task a must complete before task b can start. Return any valid execution order o...
Find longest substring with at most k distinct
Given a string s and an integer k, return the length of the longest contiguous substring that contains at most k distinct characters. Provide an O(n) ...
Design error detection and propagation algorithms
You are given three related sub-problems about error detection and propagation. A) Log search: You have a chronologically ordered array of log lines. ...
Transform tree using counterpart subtree sums
Given the roots of two complete binary trees with identical structure, modify the node values of the second tree so that each node equals the sum of a...
Implement crawler and bracket validator
Implement two tasks: ( 1) Write a function crawl(start_urls, fetch, max_depth, domain_filter) that visits pages starting from the given seed URLs usin...
Schedule dependent services with layered startup
You are given N services and dependency pairs (u -> v) meaning u must start before v. 1) Produce a valid startup order if one exists; otherwise detect...
Compute shortest path between tree nodes
You are given the root of a binary tree with unique integer values and two target values u and v. Return the sequence of node values along the shortes...
Serialize and deserialize a dictionary trie
Design and implement serialization and deserialization for a trie that stores a large dictionary of words. Requirements: compact wire format; explicit...
Set second tree values by subtree sums
Given the roots of two complete binary trees T1 and T2 that have identical structure and the same number of nodes, replace each value in T2 with the s...
Compute height after deletions; enumerate valid delete sets
Warm-up: You are given a rooted binary tree with unique node ids and a list of ids to delete. When a node is deleted, promote all of its children to b...
Serialize and deserialize a dictionary trie
Design data structures and algorithms to serialize and deserialize a dictionary trie storing lowercase English words. Specify a compact wire format th...
Find longest unique-character substring
Given a string s, return the length of the longest substring without repeating characters. Explain and implement an O(n) sliding-window solution using...
Compute shortest path between two tree nodes
Given a binary tree (not necessarily a BST) and two node values u and v, implement a function that returns the shortest path between them as a list of...
Find first error and propagate failures
You are given a chronological log history where each entry is a string prefixed with one of [Info], [Warn], or [Error]. Two invariants hold: ( 1) once...
Compute task order with prerequisites
Given an integer n representing tasks labeled 0..n-1 and a list of prerequisite pairs (a, b) meaning b must be completed before a, return any valid or...