LeetCode solutions

2502. Sort the People

My accepted Python solution to LeetCode problem 2502, Sort the People, running in 4ms.

  • Difficulty: Easy
  • Python
  • Runtime 4ms
  • Memory 17.6MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 4ms, memory 17.6MB, accepted 2026-01-01.

python
class Solution:
    def sortPeople(self, names: List[str], heights: List[int]) -> List[str]:
        paired = list(zip(heights, names))
        paired.sort(reverse=True)
        return [name for height, name in paired]

Source