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 20 problems of 100
- #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.
- #81hardsometimes asked
81. Median of Two Sorted Arrays
Find the median of two sorted arrays in O(log(min(m, n))). Snowflake asks this to test binary search on partitions — directly relevant to merging sorted micro-partitions for median computation during APPROX_PERCENTILE follow-up.
- #82hardsometimes asked
82. Regular Expression Matching
Build a regex engine for just two metacharacters — '.' matches anything, '*' repeats the previous element zero or more times — and match the WHOLE string, not a prefix. Snowflake candidates report this hard as a 2D dynamic-programming gauntlet with a domain hook a data-warehouse interviewer genuinely cares about: a SQL engine's pattern functions live or die on exactly this kind of evaluator, and the '*' branch's two transitions are where the reasoning gets graded.
- #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.
- #84hardsometimes asked
84. Reverse Nodes in k-Group
Reverse a linked list in groups of k nodes. Snowflake asks this because batched reversal in groups is precisely how their executor flips row direction in fixed-size batches for ORDER BY DESC over partial micro-partitions.
- #85hardrarely asked
85. Substring with Concatenation of All Words
Find all starting indices where a substring is a concatenation of every word exactly once. Snowflake asks this for multi-key sliding-window mastery — relevant to multi-column join-key matching in streaming joins.
- #86hardrarely asked
86. Longest Valid Parentheses
Find the longest valid parentheses substring. Snowflake asks this for stack-with-index — relevant to recovering nesting depth during SQL parser error reporting.
- #87hardrarely asked
87. Sudoku Solver
Solve a 9x9 Sudoku puzzle. Snowflake asks this to test backtracking with constraint propagation — relevant to constraint solving during type inference and constraint validation.
- #88hardsometimes asked
88. First Missing Positive
Find the smallest missing positive integer in O(n) time and O(1) space. Snowflake asks this for the cyclic-placement trick — relevant to building dense column-id mappings during data ingestion.
- #89hardsometimes asked
89. Trapping Rain Water
Compute the volume of water trapped between bars after rain. Snowflake asks this for the two-pointer trick — relevant to computing memory-bound estimation in their planner where left and right side constraints both matter.
- #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.
- #92hardrarely asked
92. N-Queens
Place n queens on an n x n chessboard so none attack each other. Snowflake asks this as the canonical backtracking-with-constraint-bitmask — relevant to constraint solving during query rewrite where multiple non-conflicting predicates must be selected.
- #93hardrarely asked
93. N-Queens II
Count the number of distinct n-queens solutions. Snowflake asks this for pure constraint counting — directly relevant to counting valid plan configurations during planner exploration.
- #94hardsometimes asked
94. Insert Interval
Insert a new interval into a sorted list of non-overlapping intervals, merging where needed. Snowflake asks this for streaming-friendly interval management — relevant to incremental micro-partition coalescing during continuous ingestion.
- #95hardrarely asked
95. Valid Number
Decide whether a string parses as a number — integer, decimal, or scientific notation — under a spec deliberately packed with corner cases ('.', '+', '1e', '.e10'). Snowflake candidates report this hard because a data-warehouse SQL parser must tokenize numeric literals exactly, and the question filters for engineers who reach for an explicit state machine instead of a clever regex they cannot defend character by character.
- #96hardrarely asked
96. Text Justification
Pack words greedily into lines of exactly maxWidth characters, distributing the leftover spaces as evenly as possible with a left bias — then break your own rules for single-word lines and the final line. Snowflake candidates report this hard not for algorithmic depth but for specification discipline: three special cases, each easy to miss, graded the way a result-set pretty-printer or fixed-width unload formatter would be — by whether every byte lands exactly where the spec says.
- #97hardsometimes asked
97. Largest Rectangle in Histogram
Find the largest rectangle area in a histogram. Snowflake asks this for the monotonic-stack pattern — directly relevant to range-max queries during query optimization.
- #98hardrarely asked
98. Maximal Rectangle
Find the largest rectangle of 1s in a binary matrix. Snowflake asks this as the 2D extension of Largest-Rectangle-in-Histogram — relevant to range-max queries over rectangular data tiles.
- #99hardrarely asked
99. Scramble String
Determine whether one string can be obtained by recursively partitioning another. Snowflake asks this for recursive partitioning with memoization — same recursion shape as proving plan equivalence under reordering.
- #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.