Convert Sparse Records to a Filled Table
Reported by candidates from Netflix's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The Netflix OA from September 2026 hands you a pile of ragged records and asks for a clean rectangular table. It's a hash-table and sorting problem dressed up as data cleanup. Most people get the happy path in ten minutes, then lose points on the empty cases: a record with no keys, or no records at all. Those are the edge cases that break a naive solution. If you blank on the live OA, StealthCoder runs invisibly as a safety net and puts a working solution on screen. Here's the script so you probably won't need it.
The problem
Each record is represented by parallel arrays keysByRow[i] and valuesByRow[i]. Keys are unique within a record, while different records may contain different keys. Return a rectangular table. Its first row is the lexicographically sorted union of all keys. Every following row corresponds to one input record in original order and contains its value under each header key, or fill when that key is absent. If there are no records, return one empty header row. Function recordsToTable(keysByRow: String[][], valuesByRow: String[][], fill: String) → String[][] Examples Example 1 keysByRow = [["name","age"],["name","city"]] valuesByRow = [["Ada","36"],["Lin","Paris"]] fill = "" return = [["age","city","name"],["36","","Ada"],["","Paris","Lin"]] The header is the sorted key union and missing cells use fill. Example 2 keysByRow = [["b"],[],["a","b"]] valuesByRow = [["2"],[],["1","3"]] fill = "NA" return = [["a","b"],["NA","2"],["NA","NA"],["1","3"]] Empty records still produce a fully filled row. Example 3 keysByRow = [] valuesByRow = [] fill = "x" return = [[]] With no records, the table contains only an empty header. Constraints 0 <= keysByRow.length == valuesByRow.length <= 100000. For each row, key and value counts are equal and keys are unique. Keys are nonempty case-sensitive strings of at most 100 characters. The total number of key-value pairs is at most 200000.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is separating the work into three passes. First, collect every key into a set and sort it lexicographically. Second, map each header key to a column index. Third, for each record, build a row prefilled with fill, then drop each value into its column using that index. Don't search per cell. With up to 100000 records and many distinct keys, a row-by-header scan gets you into trouble fast. Only touch the pairs that exist. Total pair count is capped at 200000, so the cost is dominated by sorting the unique keys. The pitfalls are the no-records case, which must return [[]] and not []. Also, empty records must still emit a full row of fill. Keys are case-sensitive, so don't normalize. If the live OA freezes your head, StealthCoder is the hedge, but this pattern is simple enough to write cold.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Convert Sparse Records to a Filled Table 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 would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Netflix's OA.
Netflix reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Convert Sparse Records to a Filled Table FAQ
How hard is the Netflix sparse records to table problem really?+
Easy to medium. There's no clever algorithm. It's a union of keys, a sort, and careful row building. The difficulty is in the edge cases, mainly empty records and an empty input, and in keeping the fill logic efficient at 100000 rows.
What's the trick to solving it fast?+
Build a sorted header, then a key-to-index hash map. For each record, create a row array of the header's length filled with the fill string, then write each value at its mapped index. That avoids per-cell lookups and keeps it linear after the sort.
What edge cases should I test before submitting?+
Test zero records, which must return [[]] with a single empty header. Test a record with no keys, which must become a full row of fill. Test keys that differ only by case, since they're distinct. Also test a fill value that's an empty string.
Is lexicographic sorting a gotcha here?+
Yes, a little. Sort by plain string comparison, not numeric or locale-aware ordering. Keys are case-sensitive, so uppercase letters sort before lowercase in standard ASCII comparison. Use your language's default string sort and you'll match the expected output.
How do I prepare in 48 hours for this kind of OA question?+
Write this one from scratch twice, then do a few hash-map grouping problems and a couple of matrix-building ones. Focus on reading constraints, handling empty input, and keeping each step linear. Then practice explaining your approach out loud in two sentences.