class Solution:
    def dominantIndex(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        n=len(nums)
        if n==0:
            return -1
        if n==1:
            return 0
        if nums[1]>nums[0]:
            index1,l1=nums[1],1
            index2,l2=nums[0],0
        else:
            index1, l1 = nums[0], 0
            index2, l2 = nums[1], 1
        for i in range(2,n,1):
            if nums[i]>index1:
                index1,index2=nums[i],index1
                l1,l2=i,l1
            elif nums[i]>index2:
                index2=nums[i]
                l2=i
        if index1>=2*index2:
            return l1
        return -1
s=Solution()
nums = [1, 2, 3, 4]
print(s.dominantIndex(nums))
# 如果没有set这一步 time limited error



