#2418
Sort the People
newbie · 120 · lc easy +12 · verified · 84.8% accepted · 1,859 likes · top 96%
Description
You are given arrays names and heights of the same length, where names[i] is the name of the ith person and heights[i] is their height.
Return names sorted in descending order of height.
Example 1:
Input: names = ["Mary","John","Emma"], heights = [180,165,170]
Output: ["Mary","Emma","John"]
Explanation: Mary is the tallest, followed by Emma and John.
Example 2:
Input: names = ["Alice","Bob","Bob"], heights = [155,185,150]
Output: ["Bob","Alice","Bob"]
Explanation: The first Bob is the tallest, followed by Alice and the second Bob.
Code
1
2
3