Snowflake Coding Interview Questions
100 Snowflake coding interview problems with full optimal solutions — 30 easy, 50 medium, 20 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an Snowflake interviewer values, and a FAQ section.
Showing 30 problems of 100
- #1easyfrequently asked
1. Two Sum
Given an array of integers and a target sum, return the indices of the two numbers that add up to target. Snowflake asks this as a warm-up to test if you can move from O(n^2) lookups to a hash-map index — the same mental jump a query planner makes when it picks a hash join over a nested-loop join.
- #2easyfrequently asked
2. Valid Parentheses
Determine whether a string of brackets is balanced. Snowflake uses this to test whether you can build a parser-like stack walk — the same primitive used to validate SQL parenthesization in their query parser.
- #3easyfrequently asked
3. Merge Two Sorted Lists
Merge two sorted linked lists into one sorted list. Snowflake asks this because it's the core primitive in a sort-merge join — and they want to see whether you handle the dummy-head pattern cleanly.
- #4easyfrequently asked
4. Remove Duplicates from Sorted Array
In-place deduplicate a sorted array, returning the new length. Snowflake asks this to test two-pointer mechanics and to set up a follow-up on dictionary-encoded columnar deduplication.
- #5easysometimes asked
5. Remove Element
Remove all instances of a target value from an array in-place. Snowflake uses this to test whether you can write a tight scan loop — the same shape as a predicate pushdown filter over a column chunk.
- #6easyfrequently asked
6. Search Insert Position
Given a sorted array and a target, return the index where the target is or where it would be inserted. Snowflake asks this to test binary-search mechanics — the same primitive used to locate a row by clustering key inside a micro-partition's min/max metadata.
- #7easysometimes asked
7. Plus One
Given a big integer represented as a digit array, add one. Snowflake uses this to test edge-case rigor — the carry propagation is the same shape as overflow handling in their NUMBER(38,0) arithmetic kernels.
- #8easyfrequently asked
8. Merge Sorted Array
Merge nums2 into nums1 in-place, both sorted, with nums1 sized to hold both. Snowflake asks this because it's the canonical 'merge in place from the back' trick — and the same trick used in external sort-merge runs.
- #9easysometimes asked
9. Binary Tree Inorder Traversal
Return the in-order traversal of a binary tree. Snowflake asks this to test whether you can produce both the recursive and the iterative-with-stack solution — relevant because their B-tree-style indexes use ordered iteration for range scans.
- #10easysometimes asked
10. Same Tree
Determine whether two binary trees are structurally identical and have the same values. Snowflake asks this as a recursion warm-up before deeper tree problems, often paired with a structural-equality follow-up on query plans.
- #11easysometimes asked
11. Symmetric Tree
Determine whether a binary tree is a mirror of itself around its center. Snowflake asks this to test paired-pointer recursion — the same pattern used to check tree balance invariants in their on-disk index structures.
- #12easyfrequently asked
12. Maximum Depth of Binary Tree
Find the depth of a binary tree. Snowflake uses this as a recursion warm-up and to set up a follow-up on B-tree fanout — the same calculation determines how many index levels a query traverses.
- #13easysometimes asked
13. Balanced Binary Tree
Decide whether a binary tree is height-balanced (every subtree's left/right heights differ by at most 1). Snowflake asks this to test whether you can fuse the 'check' and 'measure' passes into one — the same fusing the query planner does to avoid re-scanning data.
- #14easysometimes asked
14. Path Sum
Determine whether a root-to-leaf path sums to a target. Snowflake asks this to test recursion with a target accumulator — relevant for plan-cost rollup where each operator adds cost on the way up.
- #15easysometimes asked
15. Pascal's Triangle
Generate the first numRows of Pascal's triangle. Snowflake uses this to test row-at-a-time DP building — the same shape as windowing operations over a column where the next row depends on the previous one.
- #16easyfrequently asked
16. Best Time to Buy and Sell Stock
Find the max profit from one buy and one sell. Snowflake asks this to test single-pass min-tracking — the same one-pass min/max aggregation used to build column-chunk statistics during data ingestion.
- #17easysometimes asked
17. Valid Palindrome
Determine whether a string is a palindrome considering only alphanumeric characters. Snowflake uses this to test two-pointer hygiene and Unicode-aware normalization — the same normalization pipeline that runs before COLLATE comparisons in their SQL engine.
- #18easyfrequently asked
18. Single Number
Find the one number in an array where every other appears twice. Snowflake asks this because the XOR trick is exactly the same primitive used to construct erasure-coded data: cheap, commutative, parallel-friendly.
- #19easysometimes asked
19. Linked List Cycle
Determine whether a linked list has a cycle using O(1) space. Snowflake asks this because Floyd's tortoise-and-hare is a textbook example of how to convert from O(n) to O(1) auxiliary space — a recurring theme in their constant-memory streaming kernels.
- #20easyfrequently asked
20. Min Stack
Design a stack that supports push, pop, top, and getMin in O(1) time. Snowflake asks this to test whether you can co-locate state with operations — the same design principle behind their per-column aggregate accumulators.
- #21easysometimes asked
21. Two Sum II - Input Array Is Sorted
Two-sum when input is already sorted, asking for the two indices. Snowflake uses this to test whether you exploit the sortedness — the same instinct a query planner uses to pick a merge-join over a hash-join when inputs are already sorted.
- #22easysometimes asked
22. Majority Element
Find the element appearing more than n/2 times. Snowflake asks this because Boyer-Moore voting is the canonical O(1)-space streaming algorithm — and similar sketch-based algorithms underpin their approximate aggregation functions.
- #23easysometimes asked
23. Rotate Array
Rotate an array to the right by k steps in-place. Snowflake asks this to test the reverse-three-times trick — an elegant O(1) space transformation that mirrors how their executor performs in-place reorderings on column chunks.
- #24easyrarely asked
24. Reverse Bits
Reverse the bits of a 32-bit unsigned integer. Snowflake asks this to test bit-manipulation fluency — relevant for compact column encodings where they sometimes pack rotated/reversed bits to align with vectorized SIMD masks.
- #25easysometimes asked
25. Number of 1 Bits
Count the number of 1 bits in an integer (popcount). Snowflake uses this to test bit-manipulation knowledge and to set up a follow-up on bitmap-index intersection — popcount is the hot loop in bitmap predicate evaluation.
- #26easysometimes asked
26. House Robber
Maximize loot from non-adjacent houses. Snowflake asks this as a 1D-DP warm-up before harder DP problems; the rolling-two-variable variant is also a model for incremental aggregation state.
- #27easyrarely asked
27. Happy Number
Determine whether repeatedly summing the squares of a number's digits eventually reaches 1. Snowflake uses this to test cycle detection in a function-iteration setting — relevant for recursive CTE termination analysis.
- #28easysometimes asked
28. Isomorphic Strings
Decide whether two strings are isomorphic — there's a one-to-one mapping between characters. Snowflake asks this to test bijection logic — the same shape used to validate schema-to-schema column mappings during data sharing.
- #29easyfrequently asked
29. Reverse Linked List
Reverse a singly linked list. Snowflake asks this as a pointer-manipulation warm-up and to verify that you can handle the three-pointer dance — the same kind of bookkeeping required when reversing scan direction inside their executor.
- #30easyfrequently asked
30. Contains Duplicate
Decide whether an array contains any duplicate value. Snowflake uses this to test the dedup primitive — and to lead into discussions of approximate-cardinality structures like HyperLogLog, which they use for APPROX_COUNT_DISTINCT.