Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Maximum Edge on a Tree Path

A weighted tree is rooted at node 1. For each query (u, v) print the largest edge weight on the path between them (print 0 when u = v). Extend binary lifting with a max-weight table.

Constraints

1 <= n, q <= 10^5 1 <= w <= 10^9

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.