You are viewing a single comment's thread. Return to all comments →
C# solution:
public static int migratoryBirds(List<int> arr) { int result = 0; List<int> x = new List<int>() {0,0,0,0,0}; for (int i=0; i<5; i++) { for (int j=0; j<arr.Count; j++) { if(arr[j] == i+1) { x[i]++; } } } result = Result.maxValMinIndex(x) + 1; return result; } public static int maxValMinIndex(List<int> arr) { int maxVal = 0; int index = 0; for(int i=0; i<arr.Count; i++) { if(i==0 || arr[i] > maxVal) { maxVal = arr[i]; index = i; } } return index; }
Migratory Birds
You are viewing a single comment's thread. Return to all comments →
C# solution: