CAN ANYONE PLEASE TELL ME WHY MY CODE IS GIVING WRONG ANSWER OR SOMEONE WHO
HAS GOT AC IN THIS PROBLEM MAY POST HIS SOLUTION

#include<stdio.h>
main()
{
    long long int n,t,r,count,major,i;
    scanf("%lld",&t);
    while(t--)
{
    scanf("%lld",&n);
    scanf("%lld",&r);
    major=r;
    count=1;
    for(i=1;i<n;i++)
    {
        scanf("%lld",&r);
        if(r!=major)
        {
            count--;
            if(count<0)
            {        count=1;
                    major=r;
            }
        }
        else
        {
            count++;
        }
    }
    if(count<=0)
    printf("NO\n");
    else
    printf("YES%lld\n",major);
}
return 0;
}





-- 
*UTKARSH SRIVATAV*
*CSE-3
B-Tech 2nd Year
@MNNIT ALLAHABAD*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to