Given a tree of A nodes. Find the height of tree for each node taken as a root.
First argument of input contains an integer A denoting number of Nodes Second argument of input contains a (A-1) x 2 matrix denoting edges of tree.
Return an integer array of size A denoting height of each node as a root.
1 ≤ N ≤ 100000
Input 1: A = 4 , B = [[1,2],[2,3],[2,4]] Output 1: [2,1,2,2] Explanation 1: For node 1 deepest node is 3(or 4) at height 2, for node 3,4 node 1 is deepest node at height 2 and for node 2 all node are at height 1.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.