Round 1
Questions:
-
Easy string matching problem.
-
Similar to Meeting Rooms II or finding the max number of railway platforms.
-
Given a directory structure in the form of a tree with n nodes and q queries, there are 3 types of queries:
mkdir x y
-> make a folder y under xrmdir x
-> delete x from the system including its subdirectoriescount_subdir x
-> compute the total number of folders possibly immediate or non-immediate under x including itself and return the count.
Return an array of integers representing the result of the 3rd type of query in the same order they are given. Input is a list of edges.
Note: The edges do not inherently assume direction (e.g.,
[3,4], [1,4], [2,5]
). The problem states that 1 is the root, but these edges do not form a hierarchical tree/directory structure.
Candidate's Approach
- Attempted a basic DFS for the count query, handling addition and removal of edges for the mkdir and rmdir queries respectively.
- Tried forming a bi-directional graph first and then building a tree from node 1, but this approach did not work.
Interviewer's Feedback
No feedback provided.