【leetcode】面试题 01.02. 判定是否互为字符重排

 

bool CheckPermutation(char* s1, char* s2){
    int len1=strlen(s1), len2=strlen(s2);
    if(len1 != len2) return false;
    int i, hash[26]={0};
    for(i=0; i<len1; i++){
        hash[s1[i]-'a']++;
    for(i=0; i<len1; i++){
        if(hash[s2[i]-'a']-- <=0)
            return false;
    return true;
}

 

posted @ 2020-11-27 21:26  温暖了寂寞  阅读(61)  评论(0编辑  收藏  举报