public class Solution {

public int longestPalindrome(String s) {

if(s==null)return 0;

int []array=new int[58];

int res=0;

boolean flag=false;//Decide if we need to plus 1 with res

for(int i=0;i<s.length();i++)

array[s.charAt(i)-'A']++;

for(int i:array){

if(i%2==0)

res+=i;

else{

res+=i-1;

flag=true;//If there are characters that appear odd number of time, res plus 1

}

}

return flag==true? res+1:res;

}

}