You are viewing a single comment's thread. Return to all comments →
C#
public static int migratoryBirds(List<int> arr) { int mostFreq = 0; int id = 0; arr.GroupBy(id => id) .ToList() .ForEach(g => { Console.WriteLine(g.ToList().Count()); int birsFre = g.ToList().Count(); int currentId = g.First(); if(birsFre > mostFreq) { mostFreq = birsFre; id = currentId; } if(birsFre == mostFreq){ id = id < currentId ? id : currentId; } }); return id; }
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#