Algorithm · Amazon · Medium
Comment Hierarchy Printer Medium · Tree, Depth-First Search, Hash Table · Amazon, Google, Microsoft · Hints You are given an array of comment objects. Each object holds an integer id, an integer parentId, and a string text. A parentId of -1 signals that a comment is a root (no parent). Other parentId values refer to the id of another comment. Your task is to output all the comments as a hierarchical list. Follow these rules: Traverse in depth-first order: after printing a…
Checking your access…