• + 1 comment

    Hello,

    This is my solution for C#, quite easy to understand:

    class Solution {
    
            // Complete the migratoryBirds function below.
            static int migratoryBirds(int[] ar) {
    
                    int[] sightings = new int[]{0,0,0,0,0};
    
                    for(int x=0; x<ar.Length; x++)
                    {
                            sightings[(ar[x]) - 1] = sightings [(ar[x] - 1)] + 1;
                    }
    
                    int indexOfMaxValue = 0;
                     for (int x=0; x<sightings.Length; x++)
                    {
                            if (sightings[x] > sightings[indexOfMaxValue])
                            {
                                    indexOfMaxValue = x;
                            }
                     }
                    return indexOfMaxValue + 1;
    
            }