Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Salary day Bob Jones lives with his family. His family has N members with member IDs O to N - 1 . Bob Jones is

Salary day
Bob Jones lives with his family. His family has N members with
member IDs O to N-1. Bob Jones is the head of the family with
member ID O. His family has K number of earning members. Every
month, each earning member receives their salary in a particular
order and then gives it to their parent; the parent in turn gives the
salary to their parents, and so on. The salary will be given to the
highest member of the family hierarchy. If member A is the parent of
member B and if A has already received the salary, then B will keep
the salary.
For example, in the given family hierarchy A>B>C,B is the parent of
A and C is the parent of B, so if A receives the salary, then it first
goes to B, and then it goes to C but in case if C already had received
the salary then B will keep the salary of A and if in case B also
received the salary already then, A will keep the salary.
You are given two integers, N and K, where N is the total number of
members in the family, and K is the total number of earning members
in the family. You are given an array parents representing the parents
member ID, where the index represents the child's member ID. As
Bob Jones is the head of the family, he will have no parent that will
be represented by -1, and therefore, the parent array will always start
with -1. You are given an array salary_order representing the member
IDs of all the earning members of the family in the order they receive
the salary that is index O recelves the salary first and then index 1 and
so on.
Return an array containing the member ID of all members that keep
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

Does it use a maximum of two typefaces or fonts?

Answered: 1 week ago