public int hammingDistance(int x, int y) {
int hamming = x ^ y;
int cnt = 0;
while(hamming > 0){
hamming = hamming & (hamming - 1);
cnt++;
}
return cnt;
}
char[] strChars = str.toCharArray();
char[] targetChars = target.toCharArray();
int count = 0;
for (int i = 0; i < 1280; i++) {
if (strChars[i] == targetChars[i]) {
count++;
}
}
return 1280-count;
来源:51CTO
作者:shaiberni
链接:https://blog.51cto.com/1348916/2474162