Game of Thrones - I

  • + 0 comments

    If there is more than 1 letter that occurs odd number of times then there is no anagram.

    int main(){
    
        char *s = (char*)malloc(100001);
        scanf("%s",s);
        int arr[26] = {0};
        int l = strlen(s);
        for(int i = 0; i < l; i++){
            arr[s[i]-97]++; 
        }
        int countOdd = 0;
        for(int i = 0; i < 26; i++){
            if(arr[i] % 2 == 1)
                countOdd++;
            if(countOdd > 1){
                printf("NO");
                break;
            }
            if(i == 25)
                printf("YES");
        }
        
        return 0;
    }