CSES Solutions - Tree Distances II
You are given a tree consisting of n nodes. Your task is to determine for each node the sum of the distances from the node to all other nodes. Example: Input: edges = { { 1, 2 }, { 1, 3 }, { 3, 4 }, { 3, 5 } }Output: 6 9 5 8 8 Input: edges = { { 1, 2 }, { 2, 3 }, { 3, 4 }, { 3, 5 } }Output: 9 6 5 8