class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param str string字符串
* @return bool布尔型
*/
bool isUnique(string str)
{
// write code here
int cnt[52]={0};
//a~z 26~51 str[] 97 str[i] - 65 97-?=26, 97-71
//A~Z 0~25 str[] 65 str[i]-65
for(int i=0; i<=str.size()-1; i++){
if(str[i]>='a' && str[i] <= 'z'){
cnt[str[i]-71]++;
}
if(str[i]>='A' && str[i] <= 'Z'){
cnt[str[i]-65]++;
}
}
for(int i=0; i<52; i++){
if(cnt[i] >1){
return false;
}
}
return true;
}
};

京公网安备 11010502036488号