Dream11: Turn a flat CSV of nodes with parent ids into a nested JSON tree
Problem. You get a CSV string where each row is a node with an id and a parentId. Turn it into a hierarchical JSON structure. Any node whose parentId is null is a root. Every other node goes, recursively, into a children array under its parent.
Context. This was the second question in a JavaScript/platform round for a React Native SDE-2 role. The first question in the same round was writing rateLimiter(func, limit), a wrapper that lets an API-calling function run at most limit times per minute. On that one the interviewer cared a lot about edge cases, and the candidate needed hints on a few they missed.
What mattered. For the CSV-to-tree task, the interviewer wanted the approach explained clearly before coding and then working code. The post doesn't list constraints or sample data.
Comments 0
No comments yet. Ask the author something, or add what happened in your own round.