class Solution:
def sortPeople(self, names: List[str], heights: List[int]) -> List[str]:
height_to_name = {}
for h, n in zip(heights, names):
height_to_name[h] = n
res = []
for h in reversed(sorted(heights)):
res.append(height_to_name[h])
return resclass Solution:
def sortPeople(self, names: List[str], heights: List[int]) -> List[str]:
arr = list(zip(heights, names))
arr.sort(reverse=True)
return [name for _, name in arr]class Solution:
def sortPeople(self, names: List[str], heights: List[int]) -> List[str]:
indices = list(range(len(names)))
indices.sort(key=lambda i: -heights[i])
return [names[i] for i in indices]