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.16

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  2. PDFSharp生成PDF (转)

    http://www.cnblogs.com/zhouxin/p/3228108.html 在上面用OpenXML生成word后,原来利用Word2010里的导出成PDF功能就不能用. 然后找开源组件 ...

  3. Jmeter 在linux下的分布式压测

    Jmeter 在linux下的分布式压测 0.将 windows机器作为master 控制机(同时也兼做负载机slave), linux机器作为 负载机 slave. 1.linux环境安装 : (1 ...

  4. [LeetCode系列] 从中序遍历和后序遍历序列构造二叉树(迭代解法)

    给定中序遍历inorder和后序遍历postorder, 请构造出二叉树. 算法思路: 设后序遍历为po, 中序遍历为io. 首先取出po的最后一个节点作为根节点, 同时将这个节点入stn栈; 随后比 ...

  5. 最新hadoop虚拟机安装教程(附带图文)

    前两天看到有人留言问在什么情况下需要部署hadoop,我给的回答也很简单,就是在需要处理海量数据的时候才需要考虑部署hadoop.关于这个问题在很早之前的一篇分享文档也有说到这个问题,数据量少的完全发 ...

  6. Windows OS系统变量

    %userprofile% C:\Users\Administrator\ %windir% C:\Windows\

  7. C#操作VFP的dbf数据库文件实例

    C#操作VFP的dbf数据库文件实例 新一篇: js获取网站跟路径 实例中分别使用Oledb和Odbc操作vfp数据库dbf文件,操作包括:读取,增删改. 已测试可直接使用,使用方法:下面代码分两个部 ...

  8. 转!!!解释Eclipse下Tomcat项目部署路径问题(.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps)

    1.配置eclipse的开发环境,配置jdk的安装路径和tomcat安装路径. 2.在eclipse下建立Dynamic Web Project工程zhgy,在使用eclipse中new一个tomca ...

  9. 学习笔记之XML

    什么是QName - Benjieming_Wang的专栏 - CSDN博客 http://blog.csdn.net/Benjieming_Wang/article/details/5959961 ...

  10. tomcat 启动超级慢

    今天在新环境里部署tomcat, 刚开始启动很快,关闭之后再启动,却发现启动日志打印到 00:25:14.144 [localhost-startStop-1] INFO  o.s.web.conte ...