We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Migratory Birds
Migratory Birds
Sort by
recency
|
3623 Discussions
|
Please Login in order to post a comment
def migratoryBirds(arr) freq = {}
end
Python
def migratoryBirds(arr): # Write your code here res = [] for i in range(5): res.append(arr.count(i+1)) return res.index(max(res))+1
Why can't I use statistics.mode(arr) to solve it.
Here is a python solution with O(n + k) time and O(k) space: