using str.find_first_not_of


  • 0
    N

    bool detectCapitalUse(string word)
    {
    int x = word.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ",0);
    int y = word.find_first_not_of("abcdefghijklmnopqrstuvwxyz",0);
    int m = word.find_first_not_of("abcdefghijklmnopqrstuvwxyz",1);
    if(x==-1||y==-1) return true; //all capital
    if(y==0 && m==-1 ) return true; //all lower-case
    else return false; //first is capital && the other lower-case
    }


Log in to reply
 

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