8000 add 2418 · githubniraj/Leetcode@be679e3 · GitHub
[go: up one dir, main page]

Skip to content
< 8000 header class="HeaderMktg header-logged-out js-details-container js-header Details f4 py-3" role="banner" data-is-top="true" data-color-mode=light data-light-theme=light data-dark-theme=dark>

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

8000
Appearance settings

Commit be679e3

Browse files
add 2418
1 parent a975ded commit be679e3

File tree

2 files changed

+21
-0
lines changed
  • paginated_contents/algorithms/3rd_thousand
  • src/main/java/com/fishercoder/solutions/thirdthousand

2 files changed

+21
-0
lines changed

paginated_contents/algorithms/3rd_thousand/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
| 2433 | [Find The Original Array of Prefix Xor](https://leetcode.com/problems/find-the-original-array-of-prefix-xor/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2433.java) | [:tv:](https://youtu.be/idcT-p_DDrI) | Medium ||
4949
| 2432 | [The Employee That Worked on the Longest Task](https://leetcode.com/problems/the-employee-that-worked-on-the-longest-task/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2432.java) || Easy ||
5050
| 2427 | [Number of Common Factors](https://leetcode.com/problems/number-of-common-factors/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2427.java) || Easy ||
51+
| 2418 | [Sort the People](https://leetcode.com/problems/sort-the-people/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2418.java) || Easy ||
5152
| 2404 | [Most Frequent Even Element](https://leetcode.com/problems/most-frequent-even-element/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2404.java) || Easy ||
5253
| 2399 | [Check Distances Between Same Letters](https://leetcode.com/problems/check-distances-between-same-letters/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2399.java) || Medium ||
5354
| 2395 | [Find Subarrays With Equal Sum](https://leetcode.com/problems/find-subarrays-with-equal-sum/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2395.java) || Easy ||
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.fishercoder.solutions.thirdthousand;
2+
3+
import java.util.PriorityQueue;
4+
5+
public class _2418 {
6+
public static class Solution1 {
7+
public String[] sortPeople(String[] names, int[] heights) {
8+
PriorityQueue<int[]> maxHeap = new PriorityQueue<>((a, b) -> b[1] - a[1]);
9+
for (int i = 0; i < names.length; i++) {
10+
maxHeap.offer(new int[]{i, heights[i]});
11+
}
12+
String[] res = new String[names.length];
13+
int i = 0;
14+
while (!maxHeap.isEmpty()) {
15+
res[i++] = names[maxHeap.poll()[0]];
16+
}
17+
return res;
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)
0