Find the biggest possible palindrome using the characters of a given set of words

Find the biggest possible palindrome using the characters of a given set of words. If multiple palindromes of the same size could be formed, then it is enough if one of them is printed.


Input: This is a sample text for testing

Output: 15 characters



#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
 char *s;
 int len,i,count;
 int hash[256];
 memset(hash,0,sizeof(hash));
 s=(char*)malloc(sizeof(char)*256);
 gets(s);
 len=strlen(s);
 i=0;
 while(*(s+i))
 {
  if(*(s+i)!=' ')
  {
   *(s+i)=tolower(*(s+i));
   hash[*(s+i)-'a']++;
  }
  i++;
 }
 i=0;
 count=0;
 while(*(s+i))
 {
  if(*(s+i)!=' ')
  {
   if(hash[*(s+i)-'a']>=2)
   {
    while(hash[*(s+i)-'a']!=0 && hash[*(s+i)-'a']!=1)
    {
     count+=2;
     hash[*(s+i)-'a']-=2;
    }
   }
  }
  i++;
 }
 if(count < len)
      printf("%d",count+1);
 else
      printf("%d",count-1);
 return 0;
}