Leetcode 3544. Subtree Inversion Sum
Choose a set of nodes whose subtree values are negated to maximize the total sum, with the constraint that any two inverted nodes that are ancestor and descendant must be at least k edges apart. This is a rooted-tree selection problem with long-range ancestor–descendant constraints (n up to 5e4, k ≤ 50), typically solved by a tree DP tracking distances/parities of flips along paths.
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.