Skip to content

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

Sign up
Appearance settings

Commit 2e7f588

Browse files
Relative Ranks
1 parent 1e9a2ae commit 2e7f588

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

‎src/leetcode2018/RelativeRanks.java‎

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,32 @@
66
public class RelativeRanks {
77

88
public String[] findRelativeRanks(int[] nums) {
9-
Map<Integer,String> map = new HashMap<>();
10-
String[] str = new String[nums.length];
11-
int n = nums.length-1;
12-
int[] copy = new int[n+1];
13-
for(int i=0; i<= n; i++){
14-
copy[i]= nums[i];
15-
}
16-
mergeSort(nums, 0, nums.length-1);
17-
for(int i=0; i< nums.length; i++){
18-
if(i==0){
19-
map.put(nums[n-i], "Gold Medal");
20-
}
21-
else if(i==1){
22-
map.put(nums[n-i], "Silver Medal");
23-
}
24-
else if(i==2){
25-
map.put(nums[n-i], "Bronze Medal");
26-
}
27-
else{
28-
map.put(nums[n-i], (i+1)+"");
29-
}
30-
}
31-
for(int i=0; i< copy.length; i++){
32-
str[i] = map.get(copy[i]);
33-
}
34-
return str;
9+
Map<Integer,String> map = new HashMap<>();
10+
String[] str = new String[nums.length];
11+
int n = nums.length-1;
12+
int[] copy = new int[n+1];
13+
for(int i=0; i<= n; i++){
14+
copy[i]= nums[i];
15+
}
16+
mergeSort(nums, 0, nums.length-1);
17+
for(int i=0; i< nums.length; i++){
18+
if(i==0){
19+
map.put(nums[n-i], "Gold Medal");
20+
}
21+
else if(i==1){
22+
map.put(nums[n-i], "Silver Medal");
23+
}
24+
else if(i==2){
25+
map.put(nums[n-i], "Bronze Medal");
26+
}
27+
else{
28+
map.put(nums[n-i], (i+1)+"");
29+
}
30+
}
31+
for(int i=0; i< copy.length; i++){
32+
str[i] = map.get(copy[i]);
33+
}
34+
return str;
3535
}
3636

3737
public void mergeSort(int[] nums, int l, int p){

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /