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

 

 

 1 class Solution(object):
 2     def dominantIndex(self, nums):
 3         """
 4         :type nums: List[int]
 5         :rtype: int
 6         """
 7         m = max(nums)
 8         for i in nums:
 9             if i == m:
10                 continue
11             elif 2 * i > m:
12                 return -1
13         return nums.index(m)
14 
15 
16 if __name__ == '__main__':
17     solution = Solution()
18     print(solution.dominantIndex([3, 6, 1, 0]))
原文地址:https://www.cnblogs.com/panweiwei/p/12800101.html