2418. Sort the People Easy
1/**
2 * [2418] Sort the People
3 *
4 * You are given an array of strings names, and an array heights that consists of distinct positive integers. Both arrays are of length n.
5 * For each index i, names[i] and heights[i] denote the name and height of the i^th person.
6 * Return names sorted in descending order by the people's heights.
7 *
8 * Example 1:
9 *
10 * Input: names = ["Mary","John","Emma"], heights = [180,165,170]
11 * Output: ["Mary","Emma","John"]
12 * Explanation: Mary is the tallest, followed by Emma and John.
13 *
14 * Example 2:
15 *
16 * Input: names = ["Alice","Bob","Bob"], heights = [155,185,150]
17 * Output: ["Bob","Alice","Bob"]
18 * Explanation: The first Bob is the tallest, followed by Alice and the second Bob.
19 *
20 *
21 * Constraints:
22 *
23 * n == names.length == heights.length
24 * 1 <= n <= 10^3
25 * 1 <= names[i].length <= 20
26 * 1 <= heights[i] <= 10^5
27 * names[i] consists of lower and upper case English letters.
28 * All the values of heights are distinct.
29 *
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/sort-the-people/
34// discuss: https://leetcode.com/problems/sort-the-people/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39 pub fn sort_people(names: Vec<String>, heights: Vec<i32>) -> Vec<String> {
40 vec![]
41 }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48 use super::*;
49
50 #[test]
51 fn test_2418() {
52 }
53}
54
Back
© 2025 bowen.ge All Rights Reserved.