-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path08may.txt
28 lines (21 loc) · 825 Bytes
/
08may.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Solution {
public String[] findRelativeRanks(int[] score) {
int n = score.length;
int[][] sortedPairs = new int[n][2];
for (int i = 0 ; i < n ; i++) sortedPairs[i] = new int[] {i, score[i]};
Arrays.sort(sortedPairs, (x, y) -> (y[1] - x[1]));
String[] ans = new String[n];
for (int i = 0 ; i < n ; i++) {
if (i == 0) {
ans[sortedPairs[i][0]] = "Gold Medal";
} else if (i == 1) {
ans[sortedPairs[i][0]] = "Silver Medal";
} else if (i == 2) {
ans[sortedPairs[i][0]] = "Bronze Medal";
} else {
ans[sortedPairs[i][0]] = String.valueOf(i+1);
}
}
return ans;
}
}