Skip to main content

Posts

Showing posts from May, 2019

Migratory Birds HackerRank Solution in C

#include< stdio.h > int main() { long int n,i,b[ 10000 ],j,count= 0 ,t,k; long int a[ 100000 ],c[ 100000 ],p[ 100000 ]; scanf( "%ld" ,&n); for (i= 0 ;i<n;i++) { scanf( "%ld" ,&a[i]); } for (i= 0 ;i<n;i++) { if (a[i]== 1 ) { b[ 1 ]++; } if (a[i]== 2 ) { b[ 2 ]++; } if (a[i]== 3 ) { b[ 3 ]++; } if (a[i]== 4 ) { b[ 4 ]++; } if (a[i]== 5 ) { b[ 5 ]++; } } int max=b[ 1 ]; for (j= 1 ;j<= 5 ;j++) { if (max<b[j]) { max=b[j]; } } long int z= 1 ; for (j= 1 ;j<= 5 ;j++) { if (max==b[j]) { c[j]=j; count++; t=j;