• + 0 comments

    C# solution:

    public static int migratoryBirds(List arr)

    {
        arr.Sort();
        var types = arr.Distinct().ToList();
        var counts = new List<int>();
        int count = 0;        
        foreach (int type in types)
        {
            for (int i = 0; i < arr.Count; i++)
                {
                    if(arr[i] == type)
                    {
                        count++;
                    }
                }
            counts.Add(count);
            count = 0; 
        }            
    
        int indexOfType = counts.IndexOf(counts.Max());
        return types[indexOfType];
    }