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; } }