Build a comment tree out of a list of comment nodes where there is a link to a parent. The comments should come out like they would on Reddit where there are parent and child comments.
Asked in the phone screen stage. The input is a flat list of comments, each with an id, parent_id, and content. Return the same comments organized as a tree, where each node includes its content and an optional list of child comments.
def build_comment_tree(comments):
comments is a list of dictionaries with keys id, parent_id, and content.
Return a list of root comment nodes, each with id, content, and children.
def build_comment_tree(comments):