Python for beginners:
https://www.youtube.com/watch?v=egq7Z...
Code:
class Solution:
def dominantIndex(self, nums: List[int]) -> int:
f=max(nums);
rs=nums.index(f);
u=[];
g=0;
for i in nums:
if(i!=f):
u.append(i);
if(len(u)!=0):
g=max(u);
if(f>=2*g):
return rs;
else:
return -1;
0 Comments:
Post a Comment