My C Solution


  • 0
    B
    bool detectCapitalUse(char* word) {
        int prev_isupper = isupper(*word) ? 1 : 0;
    
        while(*++word) {
            if (!prev_isupper && isupper(*word)) return false;
            else if (prev_isupper > 1 && islower(*word)) return false;
            else {
                if (prev_isupper)
                    prev_isupper = isupper(*word) ? prev_isupper + 1 : 0;
            }
        }
    
        return true;
    }

Log in to reply
 

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