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]))

 

posted @ 2020-04-29 09:40  人间烟火地三鲜  阅读(172)  评论(0编辑  收藏  举报