# Heavy-Light Decomposition Path Query **Idea.** Decompose tree into heavy paths; map path queries to O(log^2 n) segment-tree ranges. ```python # sketch: dfs sizes, mark heavy child, assign positions along chains, then segtree on flat array ``` **Interview tip.** State the complexity before coding, then walk one small example by hand to show the invariant holds. *Disclosure: practice note shared by the Linkjob AI team.* For live mock-interview practice see [learn more](https://www.linkjob.ai/).