From Juspay's OA
Given a tree with N nodes and N - 1 edges. It is rooted at the node R. Each edge between Nodes Ui and Vi has a weight Wi. From this, answer Q queries of the following 2 types :
For Type 1 queries, output the sum of all edge weights in the path from A to B
Expert in Data Structures & Algorithms. Building tools to help developers crack FAANG interviews.