Created
February 20, 2020 20:40
-
-
Save BharathKumarS/12a1cbb7fd85f6a3502a9bb80055ed69 to your computer and use it in GitHub Desktop.
Find the frequent bird species with least integer value
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
def migrate(birds): | |
birds.sort() | |
FFB = my_bird = count = 0 | |
for bird in range(len(birds)-1): | |
if birds[bird] == birds[bird+1]: | |
count += 1 | |
if count > my_bird: | |
my_bird = count | |
FFB = birds[bird] | |
else: | |
count = 0 | |
return(FFB) | |
birds = [1,1,1,2,2,2,2,2,3,3,4,5,4,1] | |
frq = migrate(birds) | |
print(frq) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How is it different?
I think my code is efficient because the code is not designed only for integers between 1-5 but for any value and number of integers. Try it yourself!