← Back to blog Snowflake Coding High-Frequency Questions: Arrays + Strings + Graphs + Data Streams
Snowflake

Snowflake Coding High-Frequency Questions: Arrays + Strings + Graphs + Data Streams

2026-06-07

Snowflake's coding interviews have a distinct flavor: they do not chase obscure problems, nor do they stop at simple patterns. Questions usually come from common LeetCode medium problems, but the depth of probing is high — interviewers care whether you can reach the optimal solution quickly and clearly explain why it is optimal. A brute-force solution scores poorly even if it passes the test cases.

This article groups Snowflake's high-frequency questions into four modules — arrays, strings, graphs, and data streams — each with an optimal Python solution, complexity, and the "why" reasoning interviewers love to probe.

Snowflake Coding Interview Cheat Sheet

Dimension Detail
Platform CoderPad / built-in IDE (VO stage)
Duration 45 min per round, 1-2 questions
Difficulty Mostly LeetCode medium, leaning hard
Focus Optimal solution + complexity reasoning + robustness
Hot modules Arrays, string sliding window, graph search, heap/data stream

Type 1: Arrays — Container With Most Water (Two Pointers)

Problem

Given heights of N vertical lines, pick two to form a container with the x-axis; return the maximum water it can hold.

Approach

Brute-forcing all pairs is O(n²), unacceptable in real scenarios. Snowflake expects you to reach for two pointers immediately: shrink from both ends, always moving the shorter side.

Python Solution

def max_area(height):
    left, right = 0, len(height) - 1
    best = 0
    while left < right:
        h = min(height[left], height[right])
        best = max(best, h * (right - left))
        # move the shorter side, since area is limited by it
        if height[left] < height[right]:
            left += 1
        else:
            right -= 1
    return best

Why optimal: moving the taller side can never increase area (width shrinks, height still capped by the shorter line), so a single inward sweep suffices in O(n).

Time: O(n) Space: O(1)

Type 2: Strings — Minimum Window Substring (Sliding Window)

Problem

Given strings s and t, find the shortest substring of s containing all characters of t.

Approach

Sliding window + hash counting. Expand the right pointer until t is covered, then shrink the left pointer for the minimum. The key is maintaining window boundaries without off-by-one errors.

Python Solution

from collections import Counter

def min_window(s, t):
    need = Counter(t)
    missing = len(t)
    left = start = 0
    end = float('inf')
    for right, ch in enumerate(s):
        if need[ch] > 0:
            missing -= 1
        need[ch] -= 1
        while missing == 0:                 # window now covers t
            if right - left < end - start:
                start, end = left, right
            need[s[left]] += 1
            if need[s[left]] > 0:
                missing += 1
            left += 1
    return "" if end == float('inf') else s[start:end + 1]

Why Counter over a fixed array: t may contain arbitrary characters, so Counter is more general; if limited to lowercase letters, a fixed-size array has a smaller constant. Stating this trade-off proactively scores points.

Time: O(|s| + |t|) Space: O(|t|)

Type 3: Graphs — Course Schedule (Topological Sort, Cycle Detection)

Problem

Given a course count and prerequisites, determine whether all courses can be finished (i.e., whether the dependency graph has a cycle).

Approach

Snowflake's core systems carry complex distributed dependencies, so graph questions are frequent. Use Kahn's topological sort: dequeue zero-indegree nodes layer by layer; if fewer than the course count get dequeued, a cycle exists.

Python Solution

from collections import deque, defaultdict

def can_finish(num_courses, prerequisites):
    graph = defaultdict(list)
    indegree = [0] * num_courses
    for course, pre in prerequisites:
        graph[pre].append(course)
        indegree[course] += 1
    queue = deque(i for i in range(num_courses) if indegree[i] == 0)
    visited = 0
    while queue:
        node = queue.popleft()
        visited += 1
        for nxt in graph[node]:
            indegree[nxt] -= 1
            if indegree[nxt] == 0:
                queue.append(nxt)
    return visited == num_courses

Why Kahn over DFS: both work, but Kahn uses indegree to naturally avoid recursion depth issues and makes "why it detects a cycle" easy to explain — a queue that cannot drain means a circular dependency.

Time: O(V + E) Space: O(V + E)

Type 4: Data Streams — Median From a Stream (Two Heaps)

Problem

Design a structure supporting continuous addNum and returning the median of all numbers seen so far at any time.

Approach

This is closest to Snowflake's business. Use two heaps: a max-heap for the smaller half, a min-heap for the larger half, kept balanced in size.

Python Solution

import heapq

class MedianFinder:
    def __init__(self):
        self.lo = []  # max-heap (negated), smaller half
        self.hi = []  # min-heap, larger half

    def add_num(self, num):
        heapq.heappush(self.lo, -num)
        heapq.heappush(self.hi, -heapq.heappop(self.lo))
        if len(self.hi) > len(self.lo):       # keep lo no smaller than hi
            heapq.heappush(self.lo, -heapq.heappop(self.hi))

    def find_median(self):
        if len(self.lo) > len(self.hi):
            return -self.lo[0]
        return (-self.lo[0] + self.hi[0]) / 2

Interviewer follow-up: what if the stream does not fit in memory? A strong answer covers external sorting, bucketed counting, even approximate algorithms like t-digest.

Time: add O(log n), query O(1) Space: O(n)

Prep Strategy

Skill Focus LeetCode
Two pointers / prefix sum One-way shrink proof 11, 42, 560
Sliding window Boundary maintenance 76, 3, 438
Graph search / topo Cycle detection 207, 210, 200
Heap / data stream Two-heap balance 295, 215, 347

The core is not writing the answer but clearly explaining the reasoning, ensuring robustness, and showing how you scale as data grows.


FAQ

Q1: How hard are Snowflake's coding questions vs LeetCode? Mostly LeetCode medium leaning hard, rarely obscure. The difficulty is not the problem itself but the demand to reach the optimal solution immediately and explain why — brute force that passes tests still scores low.

Q2: What platform and duration does Snowflake use? The VO stage usually uses CoderPad or a built-in IDE, about 45 minutes per round with 1-2 questions. The emphasis is on narrating your reasoning and complexity as you code.

Q3: Which question types appear most at Snowflake? Arrays (two pointers/prefix sum), strings (sliding window), graphs (DFS/BFS/topological sort), and heaps with data streams (median/Top-K) cover the vast majority of high-frequency questions.

Q4: How do I answer "it won't fit in memory" for a stream question? Discuss external sorting, bucketing, and approximate algorithms (t-digest for medians, Count-Min Sketch for frequencies), explaining the precision-vs-memory trade-off — exactly the engineering depth Snowflake wants.

Q5: How do I prepare efficiently for Snowflake coding? Build on LeetCode high-frequency mediums, focusing on sliding window, monotonic stack, graph search, and heaps, and deliberately practice "explaining why it's optimal while coding."


Preparing for a Snowflake interview?

If you can write the answer but struggle to explain "why it's optimal," or want someone to break down question types and rehearse delivery for the VO stage, let's talk through a full OA / VO assistance plan — from optimal-solution derivation to complexity reasoning, end to end.


Contact

Need real interview questions and a custom prep plan? Message WeChat Coding0201 now and get the questions.

Email: [email protected] Telegram: @OAVOProxy