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

leetcode506的更多相关文章

  1. [Swift]LeetCode506. 相对名次 | Relative Ranks

    Given scores of N athletes, find their relative ranks and the people with the top three highest scor ...

  2. Leetcode506.Relative Ranks相对名次

    给出 N 名运动员的成绩,找出他们的相对名次并授予前三名对应的奖牌.前三名运动员将会被分别授予 "金牌","银牌" 和" 铜牌"(" ...

随机推荐

  1. hdu2602 DP (01背包)

    题意:有一个容量 volume 的背包,有一个个给定体积和价值的骨头,问最多能装价值多少. 经典的 01 背包问题不谈,再不会我就要面壁了. 终于有一道题可以说水过了 ……心好累 #include&l ...

  2. bulid-tool

    Build tool 中文构建工具.构建工具能够帮助你创建一个可重复的.可靠的.携带的且不需要手动干预的构建.构建工具是一个可编程的工具,它能够让你以可执行和有序的任务来表达自动化需求.假设你想要编译 ...

  3. 【idea】如何将idea的项目路径设置成代码目录和配置文件目录

    一:创建相应的目录 二.提升目录的等级

  4. task optimization

    Requirements: Tasks have Dependencies Running the task in Multi thread Links http://en.wikipedia.org ...

  5. FineUI 修改config表属性

    此功能可用来设置系统的不同的标题 private void SelectSystem() { ConfigHelper.Title = DropDownList1.SelectedText; Conf ...

  6. VT-x is not available. (VERR_VMX_NO_VMX) on windows 8

    've installed virtualbox on windows 8 x64, then when I open linux guest machine, I got this error me ...

  7. 关于attr("checked")的输出

    同样的一段代码,在不同的文件输出不同的答案,好神奇. console.log($("#never").attr("checked")); 一个输出checked ...

  8. 【Gearman学习笔记】分布式处理入门

    1.首先,确保你已经安装了gearmand环境并且语言绑定(language binding)已经生效. 2.涉及到的各个部分: ServerThe server, gearmand, will co ...

  9. 阿里云上部署tomcat启动后,通过http不能访问

    原因是因为阿里为了安全设置了安全组策略,必须我们授权的端口,其他计算机才能通过http访问 设置流程: 点击安全组 再点击:配置规则 然后点击:添加安全组规则 开始配置:划红线的必写,授权对象:0.0 ...

  10. java UTC时间和local时间相互转换

    java UTC时间和local时间相互转换 1.local时间转UTC时间 /** * local时间转换成UTC时间 * @param localTime * @return */ public ...