• + 0 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)