Implement Nested Comments Feature for a Comment System
Asked at Bobyard · Coding Questions · Difficulty: Easy
Given an existing comment system where the comments data now includes a `parent` field, implement a feature for nested comments such that child comments are correctly nested under their respective parent comments. Provide a Python function that handles this, taking JSON array formatted data. Each comment is an object with fields: id, content, and parent (null if a root comment). Ensure support for multiple nesting levels.
Loading the problem…
More Bobyard interview questions
- Filter Nested Comments — Keep Matched Nodes and Descendants
- Add Sorting to a Comment List with Persistence Across Refresh
- Build Nested Comments from Flat List with parentId
- Two-Team Turn-Based Battle Simulator
- Toy Language Type System
- Grid Infection and Immunity Simulation