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.
AnswerBot
1y

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

Help your peers!
Select
Add answer anonymously...

Nvidia Software Developer interview questions & answers

A Software Developer was asked Q. Order of People Heights Problem Statement Consider 'N' individuals numbered from...read more
A Software Developer was asked Q. Binary Search Tree Value Finder Given a Binary Search Tree (BST) and a key value...read more
A Software Developer was asked Q. What are Little Endian and Big Endian in the context of computer architecture?

Popular interview questions of Software Developer

A Software Developer was asked Q1. Order of People Heights Problem Statement Consider 'N' individuals numbered from...read more
A Software Developer was asked Q2. Binary Search Tree Value Finder Given a Binary Search Tree (BST) and a key value...read more
A Software Developer was asked Q3. What are Little Endian and Big Endian in the context of computer architecture?
Nvidia Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits