Snowflake's OA is 90 minutes, three problems, all code, no personality questions. The problems read like LeetCode Medium, but Snowflake's hidden tests simultaneously probe complexity ceilings, in-place matrix constraints, and I/O format requirements — miss any of those and even an "all green" sample submission loses points. This walkthrough hits three high-frequency classics: Longest Consecutive Sequence, Group Anagrams, Rotate Image — with thinking, full code, and an edge checklist. Sister piece to the Unequal Elements + String Search deep dive.
OA platform snapshot
| Dimension | Snowflake OA |
|---|---|
| Duration | ~90 min |
| Problems | 3 coding |
| Platform | HackerRank (own bank + shared with Databricks/Palantir) |
| Scoring | Per-problem score + hidden-case penalty |
| Pass line | ~75% AC + 2 problems at 100% |
| Cutoff style | Correctness over speed |
Problem 1 — Longest Consecutive Sequence (strict O(n))
Given an unsorted array of integers, return the length of the longest consecutive elements sequence. The algorithm must run in O(n).
input = [100, 4, 200, 1, 3, 2]
output = 4 # [1, 2, 3, 4]
Idea: HashSet + start-anchor check
The wrong move: sort then scan. That's O(n log n) — hidden tests TLE it.
Right move: dump everything into a set. For each x, only expand upward when x-1 is not in the set — that anchors each consecutive run at its head exactly once. Total O(n).
def longest_consecutive(nums: list[int]) -> int:
s = set(nums)
longest = 0
for x in s:
if x - 1 not in s: # x anchors a run
curr = x
length = 1
while curr + 1 in s:
curr += 1
length += 1
longest = max(longest, length)
return longest
Complexity: O(n). Edges: empty array → 0; duplicates dedup automatically via set().
Hidden-test traps
- All identical elements:
[5, 5, 5]→ 1 - Single element → 1
- Length ≥ 10⁵ → must be O(n); O(n log n) TLEs
- Negatives / zeros → set handles them, no special path needed
Problem 2 — Group Anagrams (count key beats sort)
Given an array of strings, group anagrams together. Return order is free.
input = ["eat","tea","tan","ate","nat","bat"]
output = [["eat","tea","ate"], ["tan","nat"], ["bat"]]
Idea: build a key
Most direct: key = "".join(sorted(s)). But sorted is O(L log L), giving total O(n·L·log L).
Better: 26-length count array as key (tuple it for hashing). Each string is O(L) to key, total O(n·L).
from collections import defaultdict
def group_anagrams(strs: list[str]) -> list[list[str]]:
groups = defaultdict(list)
for s in strs:
cnt = [0] * 26
for ch in s:
cnt[ord(ch) - ord('a')] += 1
groups[tuple(cnt)].append(s)
return list(groups.values())
Complexity: O(n·L).
Hidden-test traps
- Empty string
"": all empty strings group together (key = all-zero tuple) - Unicode / uppercase: spec says lowercase, but a hidden case may slip in
'A'. Defensivelower()is cheap insurance. - Single string: return
[[s]], not[s] - Output order is free, but within-group order should preserve input order
Problem 3 — Rotate Image (in-place 90° clockwise)
Given an n×n matrix, rotate it 90° clockwise in place. No O(n²) extra space.
input = [[1,2,3],
[4,5,6],
[7,8,9]]
output = [[7,4,1],
[8,5,2],
[9,6,3]]
Idea: transpose + reverse each row
Two passes, each O(n²) time and O(1) extra space:
- Transpose along the main diagonal:
matrix[i][j] ↔ matrix[j][i] - Reverse each row:
row[::-1]
def rotate(matrix: list[list[int]]) -> None:
n = len(matrix)
# Step 1: transpose
for i in range(n):
for j in range(i + 1, n):
matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
# Step 2: reverse each row
for row in matrix:
row.reverse()
Complexity: O(n²) time, O(1) space.
Hidden-test traps
- In transpose,
jstarts ati+1, not0— otherwise you swap twice and undo the work - Use
row.reverse(), notrow = row[::-1]— the latter rebinds the local name and the matrix is unchanged - 1×1 matrix → both passes are no-ops; safe to leave the loops
- Don't return the matrix — modify in place
Three-problem matrix
| Problem | Core check | Time | Space |
|---|---|---|---|
| Longest Consecutive | HashSet anchor logic | O(n) | O(n) |
| Group Anagrams | Count key vs sort | O(n·L) | O(n·L) |
| Rotate Image | Transpose + reverse | O(n²) | O(1) |
Snowflake hidden tests explicitly enforce a complexity ceiling (O(n) means no O(n log n)) or a space constraint (O(1) means no scratch matrix). That's the difference vs. casually submitting on LeetCode.
OA pacing (90 min)
00:00 - 00:05 Read all 3 problems
00:05 - 00:30 Q1: HashSet → 100% AC
00:30 - 00:55 Q2: count-key → 100% AC
00:55 - 01:20 Q3: in-place rotate → 100% AC
01:20 - 01:30 Edge sweeps (empty / single / large), resubmit each
Pacing tip: leave 5 minutes per problem for edge sweeps — chasing 100% perfection on first pass is more fragile than ship-and-resubmit. Snowflake takes the last submission, multiple submits don't penalize.
Side-by-side with Unequal Elements / String Search
| Dimension | This walkthrough | Unequal / String Search |
|---|---|---|
| Difficulty | LC Medium | LC Medium-Hard |
| Toolkit | HashSet / Counter / transpose | Sliding window / binary search |
| Explanation weight | Medium (state complexity) | High (prove monotonicity / compression) |
| Hidden-test severity | Medium | High |
If you draw this set, you'll likely have 20+ minutes left for edge sweeps. If you draw the Unequal / String Search pair, time pressure is much higher.
OA assist plug-in points for Snowflake
Standard OA assist (OA assist (OA live support)) cadence:
- Bank identification — invitation screenshot tells us within 5 minutes whether this is the "classic three" or the "deep two"
- Timed mock — 90-min pacing with the in-place / O(n) constraint vibe
- Live cueing — backstage skeleton + edge hints during the real OA
- Debrief — replay each submission within 30 minutes, list common follow-ups
- Phone-screen handoff — verbal templates ready (HashSet anchor, in-place steps)
FAQ
Q1: How many submissions are allowed? A: Unlimited. Snowflake takes the last submission, so submit a working version early and refine.
Q2: Can I write O(n log n) when O(n) isn't required? A: Yes. Group Anagrams works with sorted keys. Longest Consecutive must be O(n) — the hidden cases TLE O(n log n).
Q3: Can I use numpy.rot90 for Rotate Image?
A: No. Snowflake's platform disables third-party acceleration libraries by default. Hand-write the transpose + reverse.
Q4: Will I be auto-rejected if I can't finish all three? A: Not necessarily. Q1+Q2 at full AC plus partial cases on Q3 still has a phone-screen path. Q1 missing AC is almost always a reject.
Q5: How long from OA pass to onsite? A: Typically OA pass → phone screen within a week → onsite within 2-3 weeks. End-to-end ~4-5 weeks.
Closing
Solo on LeetCode, these three problems take ~30 minutes each. In OA context, you're being graded on complexity sensitivity + edge sweeps + submission rhythm simultaneously — that's what Snowflake actually measures. If you're prepping Snowflake / Databricks / Palantir OA, message WeChat Coding0201 with your invitation screenshot. We'll scope the bank first, then schedule OA assist.
Need real interview material? Add WeChat Coding0201 now to request access.
Contact
- WeChat: Coding0201
- Email: [email protected]
- Telegram: @OAVOProxy