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. 《DSP using MATLAB》Problem 4.1

    用到的z变换的计算公式: 代码: %% ------------------------------------------------------------------------ %% Outp ...

  2. AllJoyn 了解

    AllJoyn是一个中性平台系统,旨在简化邻近异构分布式移动通信网络系统.这里的异构性不仅表示不同的设备,而且可以是具有不同操作系统和不同类型的设备(例如个人电脑.手机.平板电脑和消费性电子产品),并 ...

  3. 【MVC】VS常用技巧

    1,在VS2010中,选中指定的代码段,可以拖拽到工具箱中,形成标签,以后还想书写类似的代码,双击鼠标即可. 2,在VS2012中,可以在注释上标注//TODO:我是注释 这样,注释就会出现在任务列表 ...

  4. 【转】每天一个linux命令(55):traceroute命令

    原文网址:http://www.cnblogs.com/peida/archive/2013/03/07/2947326.html 通过traceroute我们可以知道信息从你的计算机到互联网另一端的 ...

  5. es6比es5节省代码的地方总结

    对象方法简写: es5写法: var obj = { name: 'jeff', getName: function () { return this.name; } } es6写法(方法定义里,少写 ...

  6. CentOS6.8 x64+Nginx1.3.8/Apache-httpd 2.4.3+PHP5.4.8(php-fpm)+MySQL5.5.28+CoreSeek4.1源码编译安装

    系统为CentOS6.8 x64服务器版精简安装. 准备工作 部署安装目录 /usr/local/* /var/lib/* /var/lib64/* 下载源文件 #cd /usr/local/src ...

  7. View绘制基本知识点

    !通过阅读Android开发艺术探索整理   底层工作原理:测量流程.布局流程.绘制流程   常见回调方法:构造方法 onAttach onVisiblityChanged onDetach   Vi ...

  8. iPhone激活策略说明

    本帖最后由 苏州汇东 于 2014-7-2 19:13 编辑 奉告各位封釉 千万不要泄露机器序列号IMEI号 远程ID真的可以上  只要机器上没有ID 就可以远程上任何ID 我这可以远程上ID 也帮忙 ...

  9. 关于Jquery 插件开发,写的很清楚了。。。

    转自:http://blog.jobbole.com/30550/ 本文由 伯乐在线 - 戴嘉华 翻译.未经许可,禁止转载!英文出处:Extraordinarythoughts.欢迎加入翻译小组. 如 ...

  10. eclipse 新项目导入到tfs 步骤

    为了下次导入项目 不动脑子,写下此步骤.... 1.右键要导入的项目>> share project(如果有这项就点它,然后 进入 分享至你的tfs服务器即可) 1.右键要导入的项目> ...