You are viewing a single comment's thread. Return to all comments →
public int MaxSightings(List<int> arr) { Dictionary<int, int> sightings = new Dictionary<int, int>(); int maxSightings = 0; foreach (int i in arr) { if (sightings.ContainsKey(i)) { sightings[i]++; } else { sightings[i] = 1; } maxSightings = Math.Max(maxSightings, sightings[i]); } int birdId = sightings.Where(kv => kv.Value == maxSightings).Min(kv => kv.Key); return birdId; }
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 →