Company: Thoughtspot
Difficulty: medium
File Structure There is an existing directory structure in form of a tree with n nodes and q queries. The queries are of three types: <mkdir> <folder-x> <folder-y>: Create a folder named <folder-y> under <folder-x>. <rmdir> <folder-x>: Delete <folder-x> from the system, including its subdirectories. <count_subdir> <folder-x>: Compute the total number of folders (possibly immediate or non-immediate) under <folder-x> (including itself) and return the count. Return an array of integers representing the result of the third type of query in the same order they are given. Note: "folder-1" is always the root directory, and no query will call for it to be removed. Example Suppose existingStructureEdges = [["folder-1", "a"], ["folder-1", "b"], ["folder-1", "c"], ["a", "d"], ["a", "e"], ["e", "f"], ["c", "g"]] and queries = ["mkdir d h", "rmdir e", "count_subdir a"] Command No. Command Action Result 1 mkdir d h Create new director