leetcode506
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的更多相关文章
- [Swift]LeetCode506. 相对名次 | Relative Ranks
Given scores of N athletes, find their relative ranks and the people with the top three highest scor ...
- Leetcode506.Relative Ranks相对名次
给出 N 名运动员的成绩,找出他们的相对名次并授予前三名对应的奖牌.前三名运动员将会被分别授予 "金牌","银牌" 和" 铜牌"(" ...
随机推荐
- hdu2098 分拆素数和 素数筛
将一个偶数拆成两个素数的和,欧拉筛暴力 #include<stdio.h> #include<string.h> #define N 10001 ]; ]; ,j; void ...
- 【java规则引擎】《Drools7.0.0.Final规则引擎教程》第4章 4.2 ruleflow-group&salience
转载至:https://blog.csdn.net/wo541075754/article/details/75299888 ruleflow-group 在使用规则流的时候要用到ruleflow-g ...
- stenciljs 学习十二 官方doc 路由使用的例子
路由在单页面应用开发中是一个相对比较重要的位置 以下为官方网站的路由配置 <stencil-router scrollTopOffset={0}> <stencil-route-sw ...
- oracle 查某一列有重复值的记录
-- 查找重复记录select names,num from test where rowid != (select max(rowid) from test b ...
- apache配置禁止访问某些文件/目录
我们来看俩段通常对上传目录设置无权限的列子,配置如下: 代码如下: ? 1 2 3 4 5 6 <Directory "/var/www/upload"> <Fi ...
- Linux性能测试工具安装全集
stress 下载地址:http://people.seas.harvard.edu/~apw/stress/ 一.stress工具安装:1.获取stress源码安装包(stress-1.0.4.ta ...
- 处理json的常用java类库:Json-lib(org.json)、Gson、Jackson、Fastjson
更多的处理json的java类库,有人做了性能对比,GitHub地址:https://github.com/fabienrenaud/java-json-benchmark 处理json的java类库 ...
- JUC线程池之 线程池的5种状态:Running, SHUTDOWN, STOP, TIDYING, TERMINATED
线程池有5种状态:Running, SHUTDOWN, STOP, TIDYING, TERMINATED. 线程池状态定义代码如下: private final AtomicInteger ctl ...
- Robomongo,Mongo可视化工具
哇唔,其实她是三(阴险脸). 你看你看,界面清新,让人家心旷神怡(害羞),谁还想win+R+mongo呀呀呀?! 哎呀呀,继续···说正事. 在这里···借助SQL进一步理解下MongoDB SQL术 ...
- Number常用方法函数
Number类型应该是ECMAScript中最令人关注的数据类型了,这种类型使用IEEE754来表示整数和浮点数,并针对Number相关特点定义了一系列相关的方法函数. isFinite() 在Jav ...