Custom Record and Free-Form Field Parser
Reported by candidates from Netflix's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on this Netflix OA, reported in September 2026, is calling split(",") on the whole record. It looks like a string split problem, but commas inside a bracketed list like [x,y] are not delimiters, and that one bad split wrecks every free-form entry after it. Underneath it's string parsing with a bracket-depth check. You've got four fixed fields, a $[...]& block, two lookup maps, and output order that has to match input order. If you blank on the tokenizer mid-assessment, StealthCoder runs invisibly on your desktop as a safety net.
The problem
Parse a compact record with five top-level fields: machineCode,timestamp,field1,field2,$[key:value,key:[item,item],...]& Whitespace is insignificant. Commas inside a bracketed list do not split fields. machineEnum contains code=name entries and always maps the machine code. keyMap contains optional sourceKey=objectKey entries; an unmapped free-form key keeps its original name. Return machine_code=enumName, the three remaining fixed fields, and every free-form entry in input order as mappedKey=value. Retain repeated keys and bracketed list values. Function parseRecord(encodedRecord: String, machineEnum: String[], keyMap: String[]) → String[] Examples Example 1 encodedRecord = "123,1700,AAA,BBB,$[v1:SSS,v2:[x,y],v1:TTT]&" machineEnum = ["123=TYPE1"] keyMap = ["v1=name","v2=tags"] return = ["machine_code=TYPE1","timestamp=1700","field1=AAA","field2=BBB","name=SSS","tags=[x,y]","name=TTT"] The list comma stays inside v2 and both v1 entries are retained. Example 2 encodedRecord = "7,9,A,B,$[raw:ok]&" machineEnum = ["7=TYPE7"] keyMap = [] return = ["machine_code=TYPE7","timestamp=9","field1=A","field2=B","raw=ok"] An unmapped free-form key is preserved. Example 3 encodedRecord = "5, 10, X, Y, $[a: [1, 2, 3]]&" machineEnum = ["5=FIVE"] keyMap = ["a=values"] return = ["machine_code=FIVE","timestamp=10","field1=X","field2=Y","values=[1,2,3]"] Insignificant whitespace is removed. Constraints The record is valid and contains exactly four fixed fields plus one $[...]& block. Free-form values are nonempty scalars without delimiters or one non-nested bracketed list. Mapping keys and values contain none of ,:=[]& or whitespace.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Strip all whitespace first. Then take the first four comma-separated fields, which are safe because they have no brackets. Everything after is the free-form block between "$[" and the trailing "]&". Walk that block with a depth counter. Increment on "[", decrement on "]", and only split on a comma when depth is zero. For each entry, split on the first colon only. The key goes through keyMap, and unmapped keys stay as they are. The value stays verbatim, including its brackets. Build the machine enum map from code=name strings and look up the first field. The common pitfall is using a dictionary for the output, which silently drops repeated keys like the two v1 entries in Example 1. Use a list and append in order. Another trap is stripping the outer bracket of the block but leaving the closing "&". If you freeze on the depth-aware split during the live OA, StealthCoder is the hedge that gets you the loop quickly.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Custom Record and Free-Form Field Parser 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. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Netflix's OA.
Netflix reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Custom Record and Free-Form Field Parser FAQ
What's the trick in the Netflix record parser question?+
Split on commas only at bracket depth zero. A simple split breaks lists like [x,y]. Track depth with a counter as you scan the free-form block, cut entries at top-level commas, then split each entry on its first colon.
Why do repeated keys matter here?+
The spec says to retain repeated keys in input order. If you store results in a hash map, the second v1 overwrites the first and you fail Example 1. Append mappedKey=value strings to a list as you parse.
How should I handle whitespace?+
Remove all whitespace from the encoded record up front. The constraints say whitespace is insignificant and mapping keys contain none, so one pass of stripping makes every later step simpler. Example 3 checks exactly this case.
What happens to keys that aren't in keyMap?+
They keep their original name, as in Example 2 where raw stays raw. Build a dictionary from the keyMap strings by splitting on the equals sign, then use a get with the original key as the default.
How do I prepare for this in 48 hours?+
Practice a hand-written scanner with a depth counter, plus splitting on the first delimiter only. Write the three examples as tests. Check edge cases: a single entry, a list value last, and an empty keyMap. Nothing here needs fancy algorithms.