public class Solution
{
public int DominantIndex(int[] nums)
{
var list = new List<KeyValuePair<int, int>>();
for (int i = ; i < nums.Length; i++)
{
list.Add(new KeyValuePair<int, int>(i, nums[i]));
} var olist = list.OrderByDescending(x => x.Value).ToList();
var basenum = olist[].Value;
for (int i = ; i < olist.Count; i++)
{
if (basenum < olist[i].Value * )
{
return -;
}
}
return olist[].Key;
}
}

leetcode747的更多相关文章

  1. Leetcode747至少是其他数字两倍的最大数

    Leetcode747至少是其他数字两倍的最大数 在一个给定的数组nums中,总是存在一个最大元素 .查找数组中的最大元素是否至少是数组中每个其他数字的两倍.如果是,则返回最大元素的索引,否则返回-1 ...

  2. [Swift]LeetCode747. 至少是其他数字两倍的最大数 | Largest Number At Least Twice of Others

    In a given integer array nums, there is always exactly one largest element. Find whether the largest ...

  3. Leetcode747.Largest Number At Least Twice of Others至少是其他数字两倍的最大数

    在一个给定的数组nums中,总是存在一个最大元素 . 查找数组中的最大元素是否至少是数组中每个其他数字的两倍. 如果是,则返回最大元素的索引,否则返回-1. 示例 1: 输入: nums = [3, ...

  4. LeetCode747 至少是其他数字两倍的最大数

    在一个给定的数组nums中,总是存在一个最大元素 . 查找数组中的最大元素是否至少是数组中每个其他数字的两倍. 如果是,则返回最大元素的索引,否则返回-1. 示例 1: 输入: nums = [3, ...

随机推荐

  1. 如何修改localhost为自己指定的域名

    一般在windows电脑中localhost的配置一般都在电脑的C:\Windows\System32\drivers\etc这个路径下 ​进入后,打开hosts文件通过编辑器或者其他的软件打开,打开 ...

  2. Centos6.x搭建lnmp环境

    查看系统版本 #cat /etc/redhat-release CentOS release 6.7 (Final) 配置静态ip #vi /etc/sysconfig/network-scripts ...

  3. BZOJ2946 Poi2000 公共串 【后缀自动机】

    Description 给出几个由小写字母构成的单词,求它们最长的公共子串的长度. 任务: l 读入单词 l 计算最长公共子串的长度 l 输出结果 Input 文件的第一行是整数 n,1<=n& ...

  4. 解决 mklink 使用中的各种坑(硬链接,软链接/符号链接,目录链接)

    通过 mklink 命令可以创建文件或文件夹的链接,而这种链接跟快捷方式是不一样的.然而我们还可能会遇到其使用过程中的一些坑,本文将整理这些坑并提供解决方法.   0x00 背景介绍:mklink m ...

  5. Working out

    Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the ...

  6. Redis 字符串与哈希

    /*** * 字符串 redis里的字符串 ***/ //设置key的值 redis 127.0.0.1:6379> set key 'my name is imay' //设置值的过期时间 ( ...

  7. jsp_include

    jsp__include指令先包含后编译 include 行为 先编译后包含 <jsp:include page="head.jsp"></jsp:include ...

  8. linux中控操作相关

    1.首先生成无密码登陆密钥 一般使用rsa 2.编写shell脚本 work_dir=$(pwd) 3.远程拷贝 work_dir=$(pwd) ..} do ¥{host_prefix}$i:$ e ...

  9. 关于WCF引用方式之WCF服务寄宿控制台

    1.创建解决方案WCFService 依次添加四个项目,如上图,Client和Hosting为控制台应用程序,Service和Service.Interface均为类库. 2.引用关系 Service ...

  10. RK3288 指令查看LCD分辨率

    通过下面指令可以查看当前系统设置的分辨率. root@xxx:/ # cd sys/class/graphics/fb0 cd sys/class/graphics/fb0 root@xxx:/sys ...