Problem 3585 · Hard

Find Weighted Median Node in Tree

Walk the tree path between two nodes through their lowest common ancestor and stop at the first node that reaches half the total weight.

Open the interactive visualisation