Mr. Arulmozhivalman loves programming and he likes to face new programming challenges. After completing many challenges he has now given you one challenge which is one of his favourites. He has given you a list of N random integers and he wants you to find the integer which has the maximum frequency in the given list.Being a programmer himself, he had made this task a challenge for you and he will calculate your score for this task using a formula.Formula for calculating the score : (max_score) - (number of characters in your code/15.0)Mr. Arulmozhivalman already has a solution for this but he is not satisfied with his solution. He wants you to write a shortest possible code for this task.
#include <stdio.h>
int main()
{
int FreqArr[100000];
int Size,m=0,c=0,e=0;
int i,j;
scanf("%d",&Size);
for(i=0;i<Size;i++)
{scanf("%d",&FreqArr[i]);}
for(i=0;i<Size;i++){c=1;
for(j=1+i;j<Size;j++){
if (FreqArr[i]==FreqArr[j])
c++;}
if(m<c)
{m=c;
e=FreqArr[i];}}
printf("%d",e);
return 0;
}
Comments
Post a Comment