Reported September 2026
Snowflakestring

Length-Prefixed String Codec

Reported by candidates from Snowflake's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Snowflake OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt on this Snowflake OA, reported in September 2026, is splitting the encoded string on '#'. Values can contain '#' and digits, so that breaks fast. The task is a length-prefixed codec: encode each string as length#value, concatenate, then decode and return the encoded string followed by the decoded strings. It's a plain string parsing problem, and the whole thing hinges on trusting the length instead of the delimiter. If you blank on the decode loop mid-assessment, StealthCoder runs invisibly as a safety net and gives you the solution live.

The problem

Encode a list of strings into one string and then decode it without loss.
Use the deterministic length-prefix format length#value for each input string, concatenated with no separator. Return an array whose first element is the encoded string and whose remaining elements are the strings obtained by decoding it.
Lengths are measured in characters. The character # and decimal digits may appear inside values.

Function
encodeAndDecodeStrings(strings: String[]) → String[]

Examples
Example 1
strings = ["lint","code"]
return = ["4#lint4#code","lint","code"]
Each value is preceded by its character count and a hash delimiter.
Example 2
strings = ["","a#b","12"]
return = ["0#3#a#b2#12","","a#b","12"]
Empty strings and delimiter characters remain unambiguous because decoding trusts the length.
Example 3
strings = []
return = [""]
An empty list encodes to the empty string and decodes to no values.

Constraints
0 <= strings.length <= 10000.
0 <= strings[i].length <= 10000.
The total number of input characters is at most 200000.
Each string contains printable ASCII characters.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Encoding is easy: for each string, append its length, a '#', then the string itself. Decoding is where people lose points. Keep an index i. Scan forward from i to the next '#', parse the digits in between as n, then take exactly n characters after the '#' as the value. Move i to the end of that value and repeat. Never search for '#' inside the value, because the length already tells you where it ends. Edge cases the examples call out: an empty string encodes as 0#, and an empty list encodes to an empty string and decodes to nothing. Watch the output shape too. The first element is the encoded string, then the decoded strings. Use a list and join once, not repeated concatenation, to stay linear in total characters. If the parsing logic slips under pressure, StealthCoder is the hedge for the live OA.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Length-Prefixed String Codec cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as encode and decode strings. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Snowflake's OA.

Snowflake reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Length-Prefixed String Codec FAQ

What's the trick in the Snowflake length-prefixed string codec?+

Trust the length, not the delimiter. Find the first '#' from your current position, parse the number before it, then read exactly that many characters. Values can hold '#' and digits, so splitting on '#' fails. The length prefix is the only reliable boundary.

How hard is this problem really?+

Easy to medium. The idea is simple, but off-by-one errors in the decode loop are common. If you write the index movement carefully and test the empty string case, it's a ten-minute problem. Most failures come from sloppy pointer handling, not the concept.

How do I handle empty strings and an empty list?+

An empty string encodes as '0#' and decodes by reading zero characters after the '#'. An empty list encodes to an empty string, so the decode loop never runs. Your return is then just the empty encoded string with no decoded values after it.

What's the time complexity I should aim for?+

Linear in the total number of characters, which is at most 200000 here. Build pieces in a list and join once. Decoding makes a single pass with an index pointer. Avoid repeated string concatenation or slicing the remaining input each step, which can go quadratic.

How do I prepare for this in 48 hours?+

Write the encoder and decoder from scratch twice, then test with ["","a#b","12"] and []. Those cases catch nearly every bug. Practice parsing a multi-digit length, since lengths like 12 or 10000 span several characters before the '#'.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Snowflake.

OA at Snowflake?
Invisible during screen share
Get it