Warm up

Description:

This is a very easy warm-up problem. You are given a string. Your task is to determine whether number of occurrences of some character in the string is equal to the sum of the numbers of occurrences of other characters in the string. Input The first line of the input contains an integer T denoting the number of test cases. Each of the next T lines contains one string S consisting of lowercase latin letters. Output For each test case, output a single line containing ""YES"" if the string satisfies the condition given above or ""NO"" otherwise. Constraints 1 <= T <= 1000 1 <= length of S <= 50 Test Case 1 Input (stdin) 4 acab zzqzqq abc kklkwwww Expected Output YES YES NO YES Test Case 2 Input (stdin) 3 good beauty study Expected Output YES NO NO

Program :

#include<stdio.h>
#include<string.h>
int main()
{
 char s[200];
 int t,len,arr[26],i,f;
 scanf("%d",&t);
 while(t--)
 {
  for(i=0;i<26;i++) arr[i] = 0;
  scanf("%s",s);
  len = strlen(s);
  for(i=0;i<len;i++)
  {
   arr[s[i] - 'a']++;
  }
  f = 0;
  for(i=0;i<26;i++)
  {
   if(arr[i] == len - arr[i]) { f = 1;break; }
  }
  if(f == 1) printf("YES\n");
  else printf("NO\n");
 }
 return(0);
}