Leetcode 2421. Number of Good Paths
Count the number of distinct simple paths in a tree whose endpoints have equal values and every intermediate node has value ≤ that endpoint value (single nodes count). The core challenge is to count pairs of equal-valued nodes that are connected without passing through larger values — typically handled by processing nodes/edges in nondecreasing value and maintaining connected components (e.g., with union-find) to tally combinations per value.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.