Available question text
Given a rooted tree with edge lengths and node values, find a downward ancestor→descendant path that maximizes total edge length under the constraint that node values along the path are all distinct except that at most one value may appear twice; return the maximum length and, among all such longest paths, the minimum number of nodes. The core challenge is traversing the tree while tracking value occurrences (allowing one duplicate) to compute longest valid path length and tie-break by node count for n up to 5·10^4.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 3486. Longest Special Path II
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source