Search⌘ K
AI Features

Solution: Closest Node to Path in Tree

Solution: Closest Node to Path in Tree asks you to process tree queries, finding the node on each path between two endpoints that is closest to a target, with the smallest index breaking ties.

Statement

You are given a positive integer, n, representing the number of nodes in a tree, numbered from 00 to n−1n-1. You are also given a 2D integer array edges of length n−1n-1 ...