Company: Sprinklr_28thjuly
Difficulty: medium
Directories A company's file system is a rooted tree with N directories, numbered 1 to N . It is given as N - 1 undirected links (parent-child edges): traversal may move from a directory to its parent and to any of its children freely, so the links are walked in either direction. For every directory i , report the maximum number of links you must traverse to reach the farthest directory from i . Formally, let dist(u, v) be the number of links on the unique path between directories u and v . For every directory i you must report the largest value of dist(i, j) over all directories j . (This value is the eccentricity of i .) Input The first line contains a single integer N , the number of directories. Each of the next N - 1 lines contains two integers a and b , meaning that directories a and b are directly linked. Output Print N integers on a single line, separated by single spaces, followed by a newline. The i -th integer is the maximum number of links you must traverse to get from dire