You are viewing a single comment's thread. Return to all comments →
Here is a python solution with O(n + k) time and O(k) space:
def migratoryBirds(arr): count = {} for n in arr: if n not in count: count[n] = 0 count[n] += 1 maxval = max(count.values()) best = [] for key, val in count.items(): if val == maxval: best.append(key) return min(best)
Seems like cookies are disabled on this browser, please enable them to open this website
Migratory Birds
You are viewing a single comment's thread. Return to all comments →
Here is a python solution with O(n + k) time and O(k) space: