Zorvyn Online Assessment | Tree Distance Queries
Question · Posted Apr 2026
Problem Statement: Tree Distance Queries The Objective: You are given a weighted tree with N nodes and N−1 edges. You need to answer Q queries, where each query (u,v) asks for the shortest distance (sum of edge weights) between node u and node v. Input Format: N and Q. N−1 edges (a,b,w). Q pairs of (u,v).
The full answer & interview discussion are available to premium members.
Log in Create a free account