My solution of Valid Anagram in C(simple,no need to declare array)


  • -3
    X
    bool isAnagram(char* s, char* t) {
        int total = 0;
        if(strlen(s)!=strlen(t))
            return false;
        while((*s)!='\0')
        {
             total += (*s-*t);
            s++;
            t++;
        }
        if(total==0)
            return true;
        else
            return false;
    }

  • 0
    F

    How is this correct? Take example "ac" and "bb".. total will be 0 and not anagrams..


  • 0
    N

    NOT CORRECT AT ALL.
    怎么没有折叠功能呢?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.