Created
September 10, 2019 01:48
-
-
Save atul-chaudhary/0c242ff7b613c265e910149da464b818 to your computer and use it in GitHub Desktop.
leetcode program to find out dominant index in a list
This file contains 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: | |
def dominantIndex(self, nums) -> int: | |
m=max(nums) | |
print(m) | |
m_index=nums.index(m) | |
for i in range(len(nums)): | |
if(nums[i]==0 or nums[i]==m): | |
pass | |
elif(m//nums[i]<2): | |
return -1 | |
else: | |
return m_index | |
S=Solution() | |
m=S.dominantIndex([3,6,1,0]) | |
print(m) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment