Company: Meesho

Difficulty: medium

Problem Statement

Sub Folder Count A file system stores its folders as a tree. The folder named folder-1 is the root of that tree, and every other folder sits somewhere underneath it. The existing structure is described by a list existingStructureEdges of n pairs. Each pair [u, v] says that the folders u and v are directly connected: one of them is the immediate parent of the other. The pairs are not given in any particular direction, and they are not given in any particular order -- the parent/child relationship is decided only by the fact that folder-1 is the root. The n pairs always describe a single tree over n + 1 distinct folders. You are then given q queries, applied one after another, in the order given. There are three kinds: mkdir <folder-x> <folder-y> -- create a brand new folder named <folder-y> directly under the existing folder <folder-x> . rmdir <folder-x> -- delete the folder <folder-x> from the system, together with everything inside it (its whole sub

More Meesho OA questionsInterview experiences