Graph Theory37 sections · 1633 units
Open in Course

Reading the Clues

What the problem statement ...

Before coding, read the problem carefully. The statement reveals which technique you need.

Look for these patterns: subtree queries suggest Euler Tour. Path queries with updates suggest HLD. Counting paths by length suggests Centroid. Merging per-subtree data suggests Small-to-Large.

The number of queries matters too. If there are many queries but few updates, preprocessing with LCA or Binary Lifting is better than HLD.