HackerRank: Migratory Birds Solution in C

Given an array of bird sightings where every element represents a bird type id, determine the id of the most frequently sighted type. If more than 1 type has been spotted that maximum amount, return the smallest of their ids.

int migratoryBirds(int arr_count, int* arr) {
 int* count = malloc(sizeof(int)*20000000); 
    int id=0;
    for(int i=0; i<arr_count; i++){
    int max_count=0;
    for(int j=0; j<20000000; j++){
          id = j;   
          max_count = count[j];
 printf("%d", id);       
 return id;

Leave a Comment