Date: Seattle Nov 2018
This question was asked around 2-3 months ago. Given a hierarchy of an organization in the form of an N-ary tree. Each node of the tree has the name of the node alongwith a "FUN Score". You are the HR of the company and you are organizing a party in which you want to invite only those employees who can give Maximum Total "FUN Score". But there is one condition, if an employee is going, then his/her immediate boss cannot come to the party and vice versa.
For example, for below input, the output should be CEO(4) + VPa(4) + VPb(2) + VPc(2) = 12.
CEO is going, so MDa and MDb cannot go. MDa is not going, so VPa and VPb can go. Similarly, MDb is not going, so VPc can go.
NOTE: I have considered a binary tree below, it can be an N-ary tree.
Please help I was not able to solve this problem.
Input : There can be multiple MDs in a company and multiple VPs, so considering below tree-
CEO(4)
MDa(3) MDb(-7)
VPa(4) VPb(2) VPc(2) VPd(0)