Search
⌘K

Leetcode 2049. Count Nodes With the Highest Score

Given a rooted binary tree as a parent array, compute for each node the score defined as the product of sizes of the connected components that result when that node is removed (its child subtree sizes and the remaining complement), and return how many nodes achieve the maximum score. The core challenge is computing subtree sizes (e.g., with a DFS) and comparing the resulting products efficiently for up to 1e5 nodes.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.