Order of People Heights Problem Statement
Consider 'N' individuals numbered from 0 to N-1 standing in a queue. You are provided with two arrays: Height
and Infront
, each consisting of 'N' non-negative integers. Height[i]
indicates the height of the ith person, and Infront[i]
indicates the number of individuals who are taller than the ith person and stand in front of them in the queue.
Your task is to determine the actual order of people in the queue. The result should be an array of 'N' integers where the ith integer represents the height of the person positioned at the ith place from the front of the queue.
Example:
Input:
N = 6
Height = [5, 3, 2, 6, 1, 4]
Infront = [0, 1, 2, 0, 3, 2]
Output:
[5, 3, 2, 1, 6, 4]
Explanation:
In the resulting order, the specified conditions for the number of taller individuals in front are satisfied for each person.
Constraints:
1 <= T <= 50
1 <= N <= 10^4
1 <= Height[i] <= 10^9
0 <= Infront[i] < N
Note:
The elements in the 'Height' array are unique, ensuring a valid order always exists given the 'Height' and 'Infront' arrays. Implement the function without printing anything.
The task is to find the actual order of people in a queue based on their heights and the number of taller people in front of them.
Iterate through the given arrays and create a list of tuples containin...read more
Top Nvidia Software Developer interview questions & answers
Popular interview questions of Software Developer
Reviews
Interviews
Salaries
Users/Month