You are viewing a single comment's thread. Return to all comments →
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; }
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 →
Hello,
This is my solution for C#, quite easy to understand: