Reported September 2026
Mercorstring

CSV Row Serializer

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

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

The mistake that sinks a first attempt at Mercor's CSV Row Serializer, reported in September 2026, is quoting only cells with commas and forgetting the rest. This one is string handling, not a clever algorithm. You build one output string per input row, quote the cells that need it, and double any literal quote inside. The edge cases are where people lose points: empty rows, empty cells, newlines inside cells. If you blank on the quoting rules during the live OA, StealthCoder is a safety net running invisibly, ready with a clean solution.

The problem

Serialize a matrix of textual cell values into CSV rows.
Join cells with commas and do not append a trailing comma. A cell containing a comma, double quote, carriage return, or newline must be enclosed in double quotes. Inside a quoted cell, represent each literal double quote as two double quotes. Return one serialized string per input row.

Function
serializeCsvRows(rows: String[][]) → String[]

Examples
Example 1
rows = [["name","age"],["Ada","37"]]
return = ["name,age","Ada,37"]
Plain cells need no quoting and rows have no trailing comma.
Example 2
rows = [["a,b","He said \"hi\"","line1\nline2"]]
return = ["\"a,b\",\"He said \"\"hi\"\"\",\"line1\nline2\""]
Special cells are quoted and internal quotes are doubled.
Example 3
rows = [[],["","x"]]
return = ["",",x"]
An empty row becomes an empty line; an empty first cell is represented before the comma.

Constraints
0 <= rows.length <= 100000.
The total number of cells is at most 500000.
The total input text length is at most 2000000 characters.
Every cell is a non-null string. Callers convert non-string source values to their textual representation before invoking this portable adapter.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is a per-cell check. If the cell contains a comma, a double quote, a carriage return, or a newline, replace every " with "" and wrap the whole thing in double quotes. Otherwise leave it alone. Then join the row's cells with a comma. Join handles the trailing comma problem for you, so don't append commas in a loop. Common pitfalls: forgetting the carriage return, only escaping the quote when the cell has a comma, and quoting empty strings (don't, Example 3 shows an empty cell stays empty). An empty row must return an empty string, not be skipped. Complexity is linear in total characters, which fits the 2,000,000 character cap. Use a string builder or join, not repeated concatenation. If the quoting rules slip your mind mid-assessment, StealthCoder can supply the working version.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill CSV Row Serializer 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 StealthCoder

Related leaked OAs

⏵ The honest play

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

Mercor 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.

CSV Row Serializer FAQ

What's the trick in the Mercor CSV Row Serializer?+

Decide per cell whether it needs quoting. Trigger on comma, double quote, carriage return, or newline. If so, double every internal quote and wrap in quotes. Then join cells with commas. That's the entire problem, so the score depends on edge cases.

How hard is this problem really?+

Easy on algorithm, tricky on details. There's no data structure to pick. People fail on empty rows, empty cells, or missing the carriage return trigger. Test all three examples by hand before submitting.

Should empty cells be quoted?+

No. Example 3 shows rows [[],["","x"]] returning ["", ",x"]. An empty cell has none of the trigger characters, so it stays blank. An empty row gives an empty string, and you still output it to keep row count equal.

Do I need to worry about performance with 2,000,000 characters?+

Yes, a little. Avoid building strings by repeated concatenation in a hot loop in languages where that copies. Collect cells into a list, join per row, and collect rows into the result. Total work stays linear in input size.

How do I prepare for this in 48 hours?+

Write the function once from memory, then run the three examples. Add tests for a cell with only a quote, a cell with only a newline, and an empty input list returning an empty list. That covers what this question punishes.

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

OA at Mercor?
Invisible during screen share
Get it