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 39 problems of 100
- #33mediumsometimes asked
33. Longest Palindromic Substring
Find the longest palindromic substring of a string. Snowflake asks this to test the 'expand-around-center' insight — and how to avoid the O(n^2) memory cost of DP when streaming through a column would be cheaper.
- #34mediumsometimes asked
34. Container With Most Water
Find two lines forming the largest container of water. Snowflake uses this to test whether you can argue the correctness of the two-pointer move — the same kind of monotonic reasoning that justifies join-order pruning in their planner.
- #36mediumsometimes asked
36. Letter Combinations of a Phone Number
Generate all letter combinations from a phone-keypad digit string. Snowflake asks this to test cartesian-product generation — the same enumeration shape that underlies their CROSS JOIN and LATERAL FLATTEN execution.
- #37mediumsometimes asked
37. Remove Nth Node From End of List
Remove the n-th node from the end of a linked list in one pass. Snowflake asks this to test the two-pointer-with-gap technique — the same approach used to maintain windowed iterators over streaming row sets.
- #38mediumsometimes asked
38. Generate Parentheses
Generate all valid parenthesizations of n pairs. Snowflake uses this to test pruning during backtracking — the same instinct a query planner uses to cut off candidate-plan generation when constraints prove a partial plan can't extend to a valid full plan.
- #39mediumrarely asked
39. Swap Nodes in Pairs
Swap every two adjacent nodes in a linked list. Snowflake asks this to test pointer-manipulation precision — the same precision required when reordering rows in their pipelined executor.
- #40mediumsometimes asked
40. Next Permutation
Rearrange numbers to the lexicographically next greater permutation in place. Snowflake asks this to test whether you can articulate the three-step swap-and-reverse algorithm — a precise, in-place transformation similar to executor-side row reorderings.
- #43mediumsometimes asked
43. Valid Sudoku
Determine whether a partially-filled 9x9 Sudoku board is valid. Snowflake uses this to test multi-key uniqueness checking — the same pattern used to enforce composite unique constraints in their schema validation.
- #44mediumsometimes asked
44. Combination Sum
Find all unique combinations of candidates summing to target, with reuse allowed. Snowflake asks this to test backtracking + the 'start index' trick to avoid duplicate combinations — the same technique used to enumerate physical plans without revisiting equivalent shapes.
- #45mediumrarely asked
45. Combination Sum II
Find all unique combinations summing to target where each number can be used once, given an input that may contain duplicates. Snowflake asks this to test the sort-then-skip-equal pattern for dedup — same trick they use for DISTINCT over duplicate-laden columns.
- #46mediumsometimes asked
46. Multiply Strings
Multiply two non-negative integers represented as strings, without converting to integer types directly. Snowflake uses this as the canonical fixed-point multiplication exercise — directly relevant to NUMBER(p,s) arithmetic kernels.
- #48mediumsometimes asked
48. Rotate Image
Rotate an n x n 2D matrix 90 degrees clockwise in place. Snowflake asks this to test in-place matrix transformation — directly relevant to transpose-and-swap operations on column chunks during their executor's data shuffling.
- #50mediumrarely asked
50. Spiral Matrix
Traverse an m x n matrix in spiral order. Snowflake asks this to test boundary tracking — relevant for windowing operations over multi-dimensional storage layouts.
- #51mediumsometimes asked
51. Jump Game
Decide whether you can reach the last index. Snowflake asks this to test greedy reasoning — the same shape as deciding whether a partial plan can still be completed within a cost budget.
- #53mediumsometimes asked
53. Unique Paths
Count unique paths from top-left to bottom-right in an m x n grid moving only right or down. Snowflake asks this as a 2D-DP warm-up and to set up a follow-up on space optimization with rolling rows.
- #54mediumsometimes asked
54. Minimum Path Sum
Find the minimum-sum path from top-left to bottom-right of a grid. Snowflake uses this to test 2D-DP with state compression — the same shape they apply when computing min-cost plans over an operator DAG.
- #55mediumsometimes asked
55. Simplify Path
Simplify a Unix-style absolute path. Snowflake uses this to test stack-based parsing — relevant to their SQL parser's path resolution for staged file references like @stage/path/to/file.csv.
- #56mediumsometimes asked
56. Edit Distance
Compute the minimum edit distance between two strings (insert/delete/replace). Snowflake asks this because it's the canonical 2D-DP — and because their fuzzy-match (Jaro-Winkler, Levenshtein) UDF is built on the same recurrence.
- #57mediumsometimes asked
57. Set Matrix Zeroes
If an element is 0, set its entire row and column to 0, in place. Snowflake asks this to test in-place state propagation using existing storage as flags — same idea as encoding null bitmaps inline with column data.
- #58mediumsometimes asked
58. Search a 2D Matrix
Search a target in a matrix sorted row-major. Snowflake asks this to test 1D-as-2D binary search — same insight when treating a multi-block column store as a flat sorted sequence for predicate evaluation.
- #59mediumsometimes asked
59. Sort Colors
Sort an array of three values (0, 1, 2) in one pass. Snowflake asks this for the Dutch-National-Flag three-pointer technique — directly relevant to in-place partitioning during their executor's range repartition.
- #61mediumrarely asked
61. Combinations
Generate all combinations of k numbers from 1..n. Snowflake asks this as a backtracking template — the same enumeration shape as choosing k tables to join (Selinger-style join-order enumeration).
- #62mediumsometimes asked
62. Subsets
Generate all 2^n subsets. Snowflake asks this to test bitmask vs backtracking enumeration — and to set up a discussion of bitmask DP for join-order optimization.
- #63mediumsometimes asked
63. Word Search
Given a 2D board, find whether a word can be constructed by adjacent cells without reusing a cell. Snowflake asks this to test DFS-with-backtrack on a grid — same shape as path-discovery during dependency-graph traversal of materialized views.
- #64mediumrarely asked
64. Remove Duplicates from Sorted Array II
Remove duplicates from a sorted array so each value appears at most twice. Snowflake uses this to test the generalized 'allow k occurrences' pattern — useful for k-NN deduplication during data ingestion.
- #65mediumrarely asked
65. Search in Rotated Sorted Array II
Search in a rotated sorted array with duplicates allowed. Snowflake uses this to highlight how duplicates degrade binary search — the same concern when a clustering key is low-cardinality and pruning effectiveness drops.
- #66mediumrarely asked
66. Remove Duplicates from Sorted List II
Remove all nodes from a sorted linked list that have duplicates, leaving only distinct values. Snowflake asks this to test the dummy-head + look-ahead pattern — same shape as stream-side DISTINCT processing.
- #67mediumrarely asked
67. Partition List
Partition a linked list around a value x so that nodes < x come before nodes >= x, preserving relative order. Snowflake asks this to test two-builder pattern — same shape as range-repartition during shuffle.
- #68mediumsometimes asked
68. Decode Ways
Count the number of ways to decode a digit string into letters (A=1, B=2, ..., Z=26). Snowflake asks this for 1D DP with branching transitions — relevant to ambiguous tokenization during SQL parsing.
- #69mediumrarely asked
69. Reverse Linked List II
Reverse a linked-list sub-range from position left to right, in place. Snowflake asks this to test pointer manipulation under a tight constraint — relevant for batch-flipping micro-partitions during ORDER BY DESC over partial data.
- #70mediumrarely asked
70. Restore IP Addresses
Generate all valid IP-address splits of a digit string. Snowflake asks this to test backtracking with multi-segment constraints — same shape as parsing dotted identifiers like db.schema.table.column.
- #71mediumrarely asked
71. Unique Binary Search Trees II
Generate all structurally unique BSTs storing values 1..n. Snowflake asks this to test recursion-with-memoization and to set up a discussion on plan-tree generation — there are many ways to assemble n joins.
- #72mediumsometimes asked
72. Unique Binary Search Trees
Count the number of structurally unique BSTs storing values 1..n. Snowflake asks this for the Catalan-number DP — directly relevant to counting alternative plan shapes for n-table joins.
- #74mediumsometimes asked
74. Binary Tree Level Order Traversal
BFS a binary tree and group nodes by level. Snowflake asks this to test queue-based BFS — directly relevant to plan-tree topological traversal during cost computation.
- #75mediumrarely asked
75. Binary Tree Zigzag Level Order Traversal
BFS but alternate left-to-right and right-to-left per level. Snowflake asks this to test BFS with a flip — direct analog to alternating-direction aggregation in window functions over partitioned streams.
- #76mediumsometimes asked
76. Construct Binary Tree from Preorder and Inorder Traversal
Rebuild a binary tree from preorder + inorder traversals. Snowflake asks this to test recursive structure recovery and to set up a discussion on plan-tree deserialization.
- #78mediumsometimes asked
78. Word Break
Decide whether a string can be segmented into a sequence of dictionary words. Snowflake asks this for 1D DP with set lookup — relevant to query-rewrite where you match identifier strings against catalog tables.
- #80mediumsometimes asked
80. Longest Increasing Subsequence
Find the length of the longest strictly increasing subsequence. Snowflake asks this to test the O(n log n) patience-sort trick — directly relevant to streaming statistics maintenance over ordered data.
- #91mediumsometimes asked
91. Jump Game II
Find the minimum number of jumps to reach the last index. Snowflake asks this for BFS-style greedy with level boundaries — relevant to estimating the minimum number of repartition steps in distributed plan execution.