Problem 2479 · Hard

Maximum XOR of Two Non-Overlapping Subtrees

Compute subtree sums bottom-up, then keep the largest XOR over pairs of nodes that are not ancestor-related.

Open the interactive visualisation