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
|
3626 Discussions
|
Please Login in order to post a comment
My Python 3 O(n) solution, iterating once through array to build dictionary or hash map, then count the keys that have a value equal to maximum and append those keys to an array. If more than one key exists, the minimum does nothing:
Here is my simple C++ solution,
int migratoryBirds(vector arr) {
}
Here is my Python solution
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