Not tested (written on the phone) but should do the trick
C#
publicstaticintGetDominator(IEnumerable<int>arr){varnum=arr.Count()/2;returnarr.GroupBy(x=>x).Where(x=>x.Count()>num).OrderByDesc(x=>x.Count())//in case there are more than one.FirstOrDefault()?//pick the one most often or null, if there are none .First()??-1;}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Not tested (written on the phone) but should do the trick
C#