Leetcode Problem 2418. Sort the People

2418. Sort the People

Leetcode Solutions

Sorting by Height with Zip and Sort

  1. Zip the names and heights arrays together to create a list of (name, height) tuples.
  2. Sort the list of tuples in descending order by height.
  3. Extract the names from the sorted list of tuples.
  4. Return the list of sorted names.
UML Thumbnail

Using a Custom Comparator with Pair Objects

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...