Skip to content

Instantly share code, notes, and snippets.

@BharathKumarS
Created February 20, 2020 20:40
Show Gist options
  • Save BharathKumarS/12a1cbb7fd85f6a3502a9bb80055ed69 to your computer and use it in GitHub Desktop.
Save BharathKumarS/12a1cbb7fd85f6a3502a9bb80055ed69 to your computer and use it in GitHub Desktop.
Find the frequent bird species with least integer value
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)
@BharathKumarS
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment