首页 > 其他 > 详细

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

时间:2020-04-29 10:02:22      阅读:57      评论:0      收藏:0      [点我收藏+]

技术分享图片

 

 技术分享图片

 

 技术分享图片

 

 

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

 

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

原文:https://www.cnblogs.com/panweiwei/p/12800101.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!