
Untitled
By: a guest on
Apr 20th, 2010 | syntax:
Java | size: 0.71 KB | hits: 675 | expires: Never
public class Anagram {
int isAnagramOfPalindrome ( String S ) {
char [] tab = S.toCharArray();
HashMap<Character,Integer> map = new HashMap<Character,Integer>();
for(int i = 0; i < tab.length ; i++){
Character tmp = tab[i];
if(map.containsKey(tmp)){
Integer j = map.get(tmp);
Integer jj = j+1;
map.put(tmp, jj);
}
else{
map.put(tmp, 0);
}
}
int a = 0;
Collection col = map.values();
Integer [] val = (Integer[]) col.toArray();
for(int i = 0 ; i < val.length ; i++){
int iii = val[i].intValue();
if((val[i].intValue()%2) == 0){
}
else{
a++;
}
}
if(a==1){
return 1;
}
else{
return 0;
}
}
}