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. java BeanUtils.copyProperties

    github搜索关键词: copyPropertiesIgnore https://github.com/longyi97/GA/blob/997e9c3a467268041c186234d91c4e ...

  2. 强大的Java Json工具类

    转自: https://blog.csdn.net/u014676619/article/details/49624165 import java.io.BufferedReader; import ...

  3. SQL Server 中关于EXCEPT和INTERSECT的用法

    熟练使用SQL Server中的各种用法会给查询带来很多方便.今天就介绍一下EXCEPT和INTERSECT.注意此语法仅在SQL Server 2005及以上版本支持. EXCEPT是指在第一个集合 ...

  4. log4net保存到数据库系列一:WebConfig中配置log4net

    园子里面有很多关于log4net保存到数据库的帖子,但是要动手操作还是比较不易,从头开始学习log4net数据库日志 一.WebConfig中配置log4net 二.独立配置文件中配置log4net ...

  5. gphoto2 canon eos450d

    hjs@ubuntu:~$ gphoto2 --capture-image-and-download                                                   ...

  6. Spring本质-AOP

    一.我们在做系统设计的时候,一个非常重要的工作就是把一个大系统做分解, 按业务功能分解成一个个低耦合.高内聚的模块,就像这样: 但是分解以后就会发现有些很有趣的东西, 这些东西是通用的,或者是跨越多个 ...

  7. php单例模式实现对象只被创建一次 mysql单例操作类

    这是我在php面试题中遇到的一道试题,单例模式按字面来看就是某一个类只有一个实例,这样做的好处还是很大的,比如说数据库的连接,我们只需要实例化一次,不需要每次都去new了,这样极大的降低了资源的耗费. ...

  8. 一段简单的代码记录如何通过 js 给 HTML 设置自定义属性,并且通过点击事件获取到所设置的自定义属性值

    for (var i = 0; i <= 5; i++) { const divJoinDay = document.createElement("div"); divJoi ...

  9. centos6+nginx+php+mysql+memcached+wordpress

    centos6+nginx+php+mysql+memcached+wordpress 搭建步骤(1) LNMP 平台搭建: 请参考:http://www.cnblogs.com/ligao/p/61 ...

  10. Apache2.4.7 + php5 + mysql thinkphp

    1. LAMP 的安装sudo apt-get install apache2 2.安装PHP sudo apt-get install  libapache2-mod-php5 php5 php5- ...