Problem 43

3 comments on “Problem 43”


  • shushank

    #Pyhton Programming

    l=list(map(int,input().split(” “)))
    a1=max(l)+1
    l1=[]
    for i in range(a1):
    l1.append(0)
    for j in range(len(l)):
    a=l[j]
    l1[a]+=1
    c=max(l1)
    d=0
    for j in range(len(l1)):
    if c==l1[j]:
    print(“Type : “+str(j))
    break


  • TADEPALLI

    #include
    int max(int arr[],int n)
    {
    int i,max=0;
    for(i=0;imax)
    max=arr[i];
    }
    return max;
    }
    int main()
    {
    int i,n,cnt[]={1,2,3,4,5};
    scanf(“%d”,&n);
    int arr[n];
    for(i=0;i<n;i++)
    scanf("%d",&arr[i]);
    for(i=0;i<5;i++)
    {
    int count=0,j;
    for(j=0;j<n;j++)
    {
    if(cnt[i]==arr[j])
    {
    count++;
    }
    }
    cnt[i]=count;
    }
    for(i=0;i<5;i++)
    printf("Type %d: %d bird\n",i+1,cnt[i]);
    int maxim=max(cnt,5);
    int cnnt=0;
    for(i=0;i<5;i++)
    {
    if(cnt[i]==maxim)
    cnnt++;
    if(cnnt==1)
    {
    printf("The highest frequency is %d\n",i+1);
    break;
    }
    }
    return 0;
    }


  • Nanditha

    #include
    int main()
    {
    int n,i,max,ans;
    scanf(“%d”,&n);
    int a[n],h[6]={0};
    for(i=0;i<n;i++)
    {
    scanf("%d",&a[i]);
    h[a[i]]++;
    }
    max=h[1];
    for(i=2;i<n;i++)
    {
    if(max<h[i])
    {
    max=h[i];
    ans=i;
    }
    }
    printf("%d",ans);
    return 0;

    }