Sort the People
Sort the People
You are given two arrays, names and heights, both of length n. names[i] is the name of the i-th person, and heights[i] is their height. All heights are distinct positive integers.
Return the names array sorted such that the names correspond to people sorted by their heights in descending order.
Constraints:
n == names.length == heights.length1 <= n <= 1031 <= names[i].length <= 201 <= heights[i] <= 105names[i]consists of lower and upper case English letters.- All the values of
heightsare distinct.
Similar LeetCode problem: Sort the People
AI interview prep
Core dilemma
Efficiently associating and sorting elements based on a corresponding value, while maintaining the original association.
2 tradeoffs and 2 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Sort the People
Sort the People
You are given two arrays, names and heights, both of length n. names[i] is the name of the i-th person, and heights[i] is their height. All heights are distinct positive integers.
Return the names array sorted such that the names correspond to people sorted by their heights in descending order.
Constraints:
n == names.length == heights.length1 <= n <= 1031 <= names[i].length <= 201 <= heights[i] <= 105names[i]consists of lower and upper case English letters.- All the values of
heightsare distinct.
Similar LeetCode problem: Sort the People