Search⌘ K
AI Features

Solution: Closest Node to Path in Tree

Solution: Closest Node to Path in Tree asks you to answer each query by returning the node on a specified tree path closest to a given node, breaking ties by the smallest index.

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 ...