Available question text
Given a tree with n (≤ 3·10^4) nodes, compute for every node the sum of distances to all other nodes. This requires an O(n) tree-DP / rerooting approach (aggregate subtree sizes and distance sums, then propagate results) rather than repeated BFS from each node.
Related questions
Continue with questions that share topics or the same question type.
- Binary Search Tree to Greater Sum Tree
Coding · Binary Search Tree · Binary Tree · Depth-First Search
- Binary Tree Maximum Path Sum
Coding · Binary Tree · Depth-First Search · DP on Trees
- Find the Level of Tree with Minimum Sum
Coding
- Kth Largest Sum in a Binary Tree
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 834. Sum of Distances in Tree
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source