Skip to main content

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 73 problems of 100

  • #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.

  • #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.

  • #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.

  • #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.

  • #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.

  • #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.

  • #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.

  • #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.

  • #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.

  • #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

    Implement regex matching with . and *. Snowflake asks this for 2D DP with branching transitions — directly relevant to their REGEXP_LIKE evaluator and LIKE pattern matching.

  • #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.

  • #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.

  • #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

    Determine whether a string is a valid number (integer, decimal, or scientific notation). Snowflake asks this because their SQL parser must tokenize numeric literals correctly — and the spec is full of edge cases.

  • #96hardrarely asked

    96. Text Justification

    Justify text to a fixed width, distributing spaces evenly. Snowflake asks this to test careful greedy packing with edge-case spacing — relevant to formatted CSV unload and result-set pretty-printing.

  • #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.

Snowflake Coding Interview Questions — Full Solutions — InterviewChamp.AI