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 27 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.
- #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.
- #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.
- #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.
- #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.
- #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.
- #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.
- #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.
- #31mediumfrequently asked
31. Add Two Numbers
Add two non-negative integers stored as linked lists in reverse-digit order. Snowflake asks this to test carry propagation logic — the same arithmetic kernel that underlies their high-precision NUMBER type's addition.
- #32mediumfrequently asked
32. Longest Substring Without Repeating Characters
Find the length of the longest substring with all distinct characters. Snowflake uses this to test sliding-window mastery — the same technique their executor uses for running-distinct window functions.
- #35mediumfrequently asked
35. 3Sum
Find all unique triplets that sum to zero. Snowflake uses this to test deduplication discipline at multiple levels — the same care needed when implementing DISTINCT inside GROUP BY queries on multiple columns.
- #41mediumfrequently asked
41. Search in Rotated Sorted Array
Search for a target in a sorted array that has been rotated at an unknown pivot. Snowflake asks this to test modified binary search reasoning — the same instinct used when indexing data that may be partially ordered due to micro-partition layout.
- #42mediumfrequently asked
42. Find First and Last Position of Element in Sorted Array
Find the first and last index of a target in a sorted array. Snowflake asks this to test lower_bound/upper_bound mechanics — the same primitive used to extract row ranges for a clustered-column predicate inside a micro-partition.
- #47mediumfrequently asked
47. Permutations
Generate all permutations of a distinct-integer array. Snowflake asks this to test backtracking with a used-mask — relevant for join-order enumeration where the planner permutes table orderings to find the optimal plan.
- #49mediumfrequently asked
49. Group Anagrams
Group strings that are anagrams of each other. Snowflake asks this to test composite-key grouping — the same hashing pattern used in GROUP BY execution where you bucket rows by a normalized key.
- #52mediumfrequently asked
52. Merge Intervals
Merge overlapping intervals. Snowflake asks this to test sort-then-sweep — the same primitive used to coalesce overlapping micro-partition ranges during clustering maintenance.
- #60hardfrequently asked
60. Minimum Window Substring
Find the minimum window in s that contains all characters of t. Snowflake asks this to test sliding-window mastery with multi-character constraints — same shape as streaming join-key matching where you maintain a running multiset.
- #73mediumfrequently asked
73. Validate Binary Search Tree
Determine whether a tree is a valid BST. Snowflake asks this to test the global-constraint vs local-check distinction — same shape as validating cross-table constraints during schema changes.
- #77mediumfrequently asked
77. LRU Cache
Design an LRU cache with O(1) get and put. Snowflake asks this constantly because it's the foundation of their warehouse cache — frequently-accessed micro-partitions stay hot in SSD; cold ones get evicted by exactly this policy.
- #79mediumfrequently asked
79. Coin Change
Find the minimum number of coins that sum to a target. Snowflake asks this as the canonical 1D unbounded-knapsack — relevant to choosing min-cost combinations of cached vs cold partitions.
- #83hardfrequently asked
83. Merge k Sorted Lists
Merge k sorted linked lists into one. Snowflake asks this because it's the literal primitive for external sort-merge — when a sort spills to disk and yields k sorted runs, merging them is exactly this problem.
- #90hardfrequently asked
90. Wildcard Matching
Implement wildcard pattern matching with ? and *. Snowflake asks this because LIKE patterns in their SQL engine are exactly this matching — % maps to *, _ maps to ?, and the engine must compile patterns efficiently.
- #100hardfrequently asked
100. Serialize and Deserialize Binary Tree
Convert a binary tree to and from a string. Snowflake asks this as the canonical tree-serialization problem — directly relevant to how their distributed scheduler ships compiled query plans across compute nodes.