Maximize Bonus Payout When No Manager and Direct Report Both Receive One
Last updated: November 29, 2026
Quick Overview
An org chart is a binary tree where each node holds the bonus an employee would receive. Pick a set of employees to reward such that no chosen employee is the direct parent of another chosen employee, maximizing total bonus.
Meta
November 29, 20260
0
0 solved
An org chart is a binary tree where each node holds the bonus an employee would receive. Pick a set of employees to reward such that no chosen employee is the direct parent of another chosen employee, maximizing total bonus.
A tree DP question in Meta onsites that extends the array house-robber idea to trees. The interviewer wants each subtree to return a pair of values (with and without its root) rather than a memoized recursion that recomputes grandchildren.
What the Interviewer Expects
- Return two values per node: best if taken, best if skipped
- Combine children correctly for each case
- Avoid exponential recursion over grandchildren
- Use post-order traversal
- State O(n) time
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you report which employees were chosen?
- What if the constraint is that no two chosen nodes are within distance 2?
- How does this generalize to an n-ary org chart?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input is a binary tree root of non-negative integers, or None. Choose a subset of nodes with no chosen node adjacent to its parent. Return the maximum sum of the chosen values....
High-Level Design
For each node compute take (best sum in its subtree if the node is chosen) and skip (best if not chosen). If the node is taken, its children must be skipped: take = val + left.skip + right.skip....