← Back to blog Snowflake OA Deep Dive — Unequal Elements + String Search Walkthrough
Snowflake

Snowflake OA Deep Dive — Unequal Elements + String Search Walkthrough

2026-05-31

Snowflake is the bellwether of the cloud data-warehouse space, and the OA carries the same data-infra DNA: no brain teasers, but every problem demands algorithm + complexity + edges all locked at once. Pass only the sample cases and the hidden tests will quietly drop you below cutoff. This walkthrough unpacks two real OA problems that the Snowflake OA three-problem walkthrough doesn't cover: Unequal Elements and String Search.

Problem 1 — Unequal Elements (longest subsegment with ≤ k transitions)

Given an array skills of length n, find the longest subsegment such that the number of transitions between different skill values is at most k.

Idea: compress into groups, then sliding window

def max_subseq_with_k_transitions(skills: list[int], k: int) -> int:
    if not skills:
        return 0

    # Step 1: compress consecutive duplicates into groups
    groups = []
    curr, count = skills[0], 1
    for x in skills[1:]:
        if x == curr:
            count += 1
        else:
            groups.append((curr, count))
            curr, count = x, 1
    groups.append((curr, count))

    # Step 2: slide; window may contain at most k+1 distinct groups
    max_len = 0
    left = 0
    window_sum = 0
    for right in range(len(groups)):
        window_sum += groups[right][1]
        while right - left > k:
            window_sum -= groups[left][1]
            left += 1
        max_len = max(max_len, window_sum)
    return max_len

Complexity: O(n).

Hidden-test edge checklist

The line that traps most candidates: the window holds at most k+1 distinct groups (k transitions ⇒ k+1 segments). Get the +1 wrong and every test case breaks.

Problem 2 — String Search (max removals while target stays a subsequence)

Given a source string and a target string, characters of source are removed in the order specified by order. Find the largest k such that, after removing the first k characters indicated by order, target is still a subsequence of the remaining source.

source = "abbabaa"
target = "bb"
order  = [6, 0, 1, 4, 3, 2, 5]

Idea: binary-search on k, with subsequence check

A direct simulation is O(n²). Snowflake's hidden tests push len(source) ≤ 10^5; you must binary-search.

def get_max_removals(order: list[int], source: str, target: str) -> int:
    def is_subseq_after_remove(k: int) -> bool:
        removed = [False] * len(source)
        for i in range(k):
            removed[order[i]] = True
        t = 0
        for i, ch in enumerate(source):
            if not removed[i] and t < len(target) and ch == target[t]:
                t += 1
                if t == len(target):
                    return True
        return t == len(target)

    lo, hi, ans = 0, len(source), 0
    while lo <= hi:
        mid = (lo + hi) // 2
        if is_subseq_after_remove(mid):
            ans = mid
            lo = mid + 1
        else:
            hi = mid - 1
    return ans

Complexity: O(n log n).

Why monotonicity holds (frequent follow-up)

"Why does binary search even apply?"

If removing k characters still leaves target as a subsequence, removing fewer characters (a subset of those positions) trivially still does. Feasibility is monotone in k, so binary search applies. State this proactively — Snowflake reviewers dock points if you don't justify the monotonicity.

Hidden-test edge checklist

Two-problem comparison

Dimension Unequal Elements String Search
Core algorithm Sliding window Binary search + subsequence check
Complexity O(n) O(n log n)
Top hidden trap k+1 vs k binary bounds / empty target
Common follow-up Why compress into groups Why monotonicity holds

The interesting bit: the algorithms aren't hard, but explanation weight is high. The OA platform won't grade narrative directly, but the follow-up phone screen almost always asks "why," so you should annotate the code clearly during the OA itself.

OA pacing (90-minute version)

00:00 - 00:05  Skim all 3 problems, pick the easiest first
00:05 - 00:25  Q1 (familiar) → 100% AC
00:25 - 00:55  Q2 (mid) → 80%+ AC, leave 10 min as fallback
00:55 - 01:20  Q3 (hard) → ship brute force first for partial AC
01:20 - 01:30  Sweep edge cases across all submissions

If Unequal Elements or String Search shows up, prioritize them — sample cases are thin but hidden cases are punishing. Hitting AC on those two often determines pass/fail.

OA assist plug-in points for Snowflake

Standard OA assist (OA assist (OA live support)) cadence on Snowflake:

  1. Question-bank scoping — recruit signals tell us whether you're hitting Snowflake's own bank or the shared Databricks / Palantir set
  2. Timed mock — 90-min sim, drilling the "brute first → optimize" submission rhythm
  3. Live cueing — backstage skeleton + hidden-test edge hints during the real OA
  4. Debrief — replay each submission within 5 minutes to find lost-edge cases
  5. Phone-screen handoff — once OA passes, build "monotonicity / complexity" explanation templates for the next round

FAQ

Q1: How long to hear back after Snowflake OA? A: Usually 3-7 business days. Snowflake doesn't reveal scores; you'll get a phone-screen invite or a rejection.

Q2: Are partial AC submissions accepted? A: Yes, but the cutoff is around "1 full AC + 2 with partial cases." Three full AC almost always advances.

Q3: Is Python mandatory? A: No — Python / Java / C++ / Go all work. Python is fastest to write for binary-search-on-answer problems like String Search.

Q4: Is there a live proctor watching? A: No, asynchronous grading. Submissions are stored and may be revisited during phone screen.

Q5: How many rounds after OA? A: Typically 1 phone screen + 4-5 onsite. Phone screen has ~50% chance of revisiting an OA problem and asking for the verbal walkthrough.

Closing

The real difficulty in Snowflake OA is "algorithm correct but explanation thin" — you got it right and still couldn't say why. If you're prepping Snowflake / Databricks / Palantir data-infra roles, message WeChat Coding0201 with your JD and the OA invitation screenshot. We'll scope the question bank first, then pace OA assist accordingly.


Need real interview material? Add WeChat Coding0201 now to request access.


Contact