llllmz

导航

389. 找不同c

 

 

 

char findTheDifference(char* s, char* t) {
    int temps[26]={0};
    int tempt[26]={0};
    int n1=strlen(s),n2=strlen(t);
    for(int i=0;i<n1;i++) temps[s[i]-'a']++;
    for(int i=0;i<n2;i++) tempt[t[i]-'a']++;
    int i=0;
    for(;i<26;i++){
        if(temps[i]!=tempt[i]) break;
    }
    return 'a'+i;
}

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