Company: intuit_1march
Difficulty: medium
A database is represented as a rooted tree with tree_nodes tables, where Table 1 is the root. Up to max_operations operations are allowed. In one operation: Select a child table u of a parent table v and remove the edge ( u , v ). Move u (and its subtree) to become a direct child of the root, reducing its depth. Determine the minimum possible height of the tree. Note: The height of the tree is defined as the maximum depth of any table. The depth of a table is the number of edges from the root to that table. A subtree in a rooted tree is a subgraph of the tree consisting of a vertex (the root) and its descendants, along with all edges incident to these descendants. Example tree_nodes = 4 tree_from = [3, 1, 2] tree_to = [2, 3, 4] max_operations = 1 One possible operation can be: Remove the edge (2, 4) and add an edge (1, 4). So, the height of the tree is 2. Function Description Complete the function getMinimumHeight in the editor with the following parameters: int tree_nodes : the number