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.
{
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];
}
Cookie support is required to access HackerRank
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 →
C# solution:
public static int migratoryBirds(List arr)