Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
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.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.