llllmz

导航

面试题 01.01. 判定字符是否唯一c

\


bool isUnique(char* astr){
    int temp[26]={0};
    for(int i=0;i<strlen(astr);i++){
        temp[astr[i]-'a']++;
    }
    for(int i=0;i<26;i++){
        if(temp[i]>1) return false;
    }
    return true;
}

结果:

posted on 2024-03-15 22:51  神奇的萝卜丝  阅读(14)  评论(0)    收藏  举报