Given a connected, undirected tree with n nodes, labeled from 0 to n−1, and n−1 edges. The edges are provided in an array, where each element edges[i] =[ai,bi] represents an edge between nodes ai and bi.
Your task is to return an array ans of length n, where ans[i] is the total sum of the distances between the ith node and all other nodes in the tree.
Constraints: