public class Solution {
public string[] FindRelativeRanks(int[] nums) {
var list = nums.OrderByDescending(x => x).ToList();
var count = nums.Count(); Dictionary<int, string> dic = new Dictionary<int, string>(); string[] ary = new string[count]; for (int i = ; i < count; i++)
{
if (i == )
{
dic.Add(list[i], "Gold Medal");
}
else if (i == )
{
dic.Add(list[i], "Silver Medal");
}
else if (i == )
{
dic.Add(list[i], "Bronze Medal");
}
else
{
dic.Add(list[i], (i + ).ToString());
}
} for (int i = ; i < count; i++)
{
ary[i] = dic[nums[i]];
} return ary;
}
}

https://leetcode.com/problems/relative-ranks/#/description

05-11 22:06