• + 1 comment
      
            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;
    
            }