Quiet Org Chart Bonus
Preview mode. Log in to edit, run, submit, and save progress.
Quiet Org Chart Bonus
An organization chart is stored as a binary tree in level-order form. A value of -1 marks a missing employee. Each present employee has a bonus value. The company cannot assign bonuses to both an employee and that employee's direct manager. Choose any set of employees that obeys this restriction and maximizes total bonus. Input Format: You are given an integer array levelOrder. Output Format: Return the maximum total bonus that can be assigned.
Examples
levelOrder = [3, 2, 3, -1, 3, -1, 1]
7
Explanation: At the root, taking it gives 7, while skipping it gives 6. The best quiet bonus is 7, so the output is 7.
Approach hint
Each node has two states: selected or skipped.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.