Created
August 12, 2018 11:09
-
-
Save luojiyin1987/910737b1a67fff4ebfb9eadca37fe406 to your computer and use it in GitHub Desktop.
Largest Number At Least Twice of Others
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution(object): | |
| def dominantIndex(self, nums): | |
| """ | |
| :type nums: List[int] | |
| :rtype: int | |
| """ | |
| maxn = max(nums) | |
| for num in nums: | |
| if num != maxn and 2 * num > maxn: | |
| return -1 | |
| return nums.index(maxn) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment