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 名运动员的成绩,找出他们的相对名次并授予前三名对应的奖牌.前三名运动员将会被分别授予 "金牌","银牌" 和" 铜牌"(" ...
随机推荐
- 《DSP using MATLAB》Problem 4.24
Y(z)部分分式展开, 零状态响应部分分式展开, 零输入状态部分分式展开,
- Flask第31课——include标签
我们在上一节代码基础上增加一些代码,样式: 文件名index.html,代码: {% from 'macros/forms.html' import input %} <!DOCTYPE htm ...
- python 2个dict如何合并
dictMerged2 = dict( dict1, **dict2 ) 这种效率比较高 refer to: http://www.pythoner.com/13.html
- Makefile在内核编译中的使用
1.一个配置选项选中多个文件 path:drivers/media/i2c/adv748x adv748x-objs := \ adv748x-afe.o \ adv748x-core.o \ adv ...
- MySQL Disk--SSD与RAID
===================================================SSD与RAID 51.在RAID 5这类Parity-RAID上存在partial-stripe ...
- Linux下的Nginx、php、mysql、apache部署
待补充,先搞几个博客链接: https://www.cnblogs.com/Candies/p/8282934.html http://sujianjob.com/2017/12/18/yum%E5% ...
- vs2013下OpenGL环境的配置
1.下载glut库:https://files.cnblogs.com/files/laoxia/glutdlls37beta.zip 2.解压后,将glut.lib和glut32.lib两个文件拷贝 ...
- Application 应用对象
在整个服务器运行过程中,application对象只有一个 下面的例子是访问次数的统计 <%@ page language="java" contentType=" ...
- PHP 图片打水印
<?php /*----------------------------------------------------------------------------------- *函数名称 ...
- linux 搭建 redis
找了很多教程总有一个适合我 http://www.cnblogs.com/_popc/p/3684835.html 当然我的目录是/opt/redis 文章中的目录是/usr/local/redi ...