public boolean isUniqueChars2(String str) {
int checker = 0;
for (int i = 0; i < str.length(); i++) {
int val = str.charAt(i) - ‘a‘; //保证val的值不超过26
if ((checker & (1 << val)) > 0) {
return false;
} else {
checker |= (1 << val);//checker=checker | (1<<val)
}
}
return true;
}
CC150 1.1 字符串查唯一bit manipulation详解,布布扣,bubuko.com
CC150 1.1 字符串查唯一bit manipulation详解
原文:http://www.cnblogs.com/tonychiang/p/3912766.html