Company: intuit_1march
Difficulty: medium
Minimum Height A database schema is stored as a rooted tree of tree_nodes tables numbered 1 through tree_nodes . Table 1 is the root. The depth of a table is the number of edges on the path from the root down to it, and the height of the tree is the largest depth of any table. Deep tables are expensive to reach, so the schema can be flattened. In one operation you: pick any table u other than the root, whose current parent is v ; delete the edge (u, v) ; attach u directly under the root, i.e. add the edge (1, u) . The whole subtree of u moves with it: u lands at depth 1 , and every descendant of u keeps its distance to u . Given the tree and a budget of max_operations , report the smallest height the tree can have after performing at most max_operations operations. Input Format The first line contains the integer tree_nodes . Each of the next tree_nodes - 1 lines contains two integers tree_from[i] and tree_to[i] , the endpoints of the i -th edge. Edges are undirected : an edge may be l