zoukankan      html  css  js  c++  java
  • leetcode747

    public class Solution
        {
            public int DominantIndex(int[] nums)
            {
                var list = new List<KeyValuePair<int, int>>();
                for (int i = 0; i < nums.Length; i++)
                {
                    list.Add(new KeyValuePair<int, int>(i, nums[i]));
                }
    
                var olist = list.OrderByDescending(x => x.Value).ToList();
                var basenum = olist[0].Value;
                for (int i = 1; i < olist.Count; i++)
                {
                    if (basenum < olist[i].Value * 2)
                    {
                        return -1;
                    }
                }
                return olist[0].Key;
            }
        }
  • 相关阅读:
    bzoj1009
    bzoj1576 3694
    bzoj3143
    bzoj1391
    bzoj2729
    bzoj2653
    bzoj3261
    bzoj2326
    人件
    优秀的产品
  • 原文地址:https://www.cnblogs.com/asenyang/p/9734433.html
Copyright © 2011-2022 走看看