解:
class Solution { public int dominantIndex(int[] nums) { for(int i = 0 ; i < nums.length ; i ++ ) { int max = nums[i]; for(int k = 0 ; k < nums.length ; k ++ ) { if(max < nums[k] * 2 && k != i ) { break; } if(k == nums.length -1) { return i; } } } return -1 ; } }
原文地址:https://www.cnblogs.com/1-Admin/p/12147043.html
时间: 2024-10-05 00:21:43