Ctrl K

Tallest-First Roll Call

Easy
A coach lines up the team by height. You are given two arrays of the same length: people[i] is the name of player i and heights[i] is their height in millimeters. All heights are distinct, but names may repeat. Return the players' names in the order they will stand in line, from the tallest to the shortest.
Example 1
people=['Oleg', 'Nina', 'Pavel'], heights=[176, 182, 169] → ['Nina', 'Oleg', 'Pavel']

Nina is the tallest (182), then Oleg (176), and Pavel (169) comes last.

Example 2
people=['Sam', 'Lea', 'Sam'], heights=[150, 171, 190] → ['Sam', 'Lea', 'Sam']

Names may repeat: the second Sam is the tallest and the first Sam is the shortest.

Constraints
  • 1 ≤ len(people) = len(heights) ≤ 10⁵
  • 1 ≤ len(people[i]) ≤ 20, names use upper- and lowercase English letters
  • 1 ≤ heights[i] ≤ 10⁵
  • all heights[i] are distinct
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsDrop Adjacent Anagrams EasyAnagram Buckets MediumA Subsequence of One Word Only MediumMost Searched Words MediumWord Grown Letter by Letter Medium
loading Python…
Input
people=['Oleg', 'Nina', 'Pavel'], heights=[176, 182, 169]
Expected
['Nina', 'Oleg', 'Pavel']

Run checks the first 3 tests in your browser. Submit checks all 121 tests on the server, hidden ones included.