Set .symmetric_difference() Operation

  • + 0 comments

    I believe this code is faster , u can easily aviod extra loop of 26 elements

    char* pangrams(char* s) { int i =0; int table[52] = {0};

    int alphabet_cnt = 0;
    
    while(s[i] != '\0'){
    
        if(s[i]>=65 && s[i] <= 90){
            if(table[s[i] - 65] == 0 && table[s[i] - 65 + 26] == 0 ){
                alphabet_cnt++;
                table[s[i] - 65]++;
            }
        }
        else  if(s[i]>=97 && s[i] <= 122 ){
            if(table[s[i] - 71] == 0 && table[s[i] - 71 - 26] == 0){
                alphabet_cnt++;
                table[s[i] - 71]++;
            }
    
        }
        i++;
    }
    
    if(alphabet_cnt == 26)
        return "pangram";
    
    return "not pangram";
    

    }