We define the usage of capitals in a word to be right when one of the following cases holds:


	All letters in this word are capitals, like "USA".
	All letters in this word are not capitals, like "leetcode".
	Only the first letter in this word is capital, like "Google".


Given a string word, return true if the usage of capitals in it is right.

&nbsp;
Example 1:
Input: word = "USA"
Output: true
Example 2:
Input: word = "FlaG"
Output: false

&nbsp;
Constraints:


	1 &lt;= word.length &lt;= 100
	word consists of lowercase and uppercase English letters.


class Solution:
    def detectCapitalUse(self, word: str) -> bool:
        l=len(word)
        if l==1:
            return True
        if word[0]==word[0].lower() and word[1]==word[1].upper():
            return False
            
        u=False
        if word[0]==word[0].upper():
            if word[1]==word[1].upper():
                u=True
                
        for i in word[2:]:
            if i==i.upper() and u==False:
                return False
            elif i==i.lower() and u==True:
                return False
        return True
class Solution {
    public boolean detectCapitalUse(String word) {
        int count = 0;
        for(int i=0; i < word.length(); i++){
            if('A' <= word.charAt(i) && word.charAt(i) <= 'Z')
                count++;
        }
        if(count == 0 || count == word.length() || (count == 1 && ('A' <= word.charAt(0) && word.charAt(0) <= 'Z')))
            return true;
        else
            return false;
    }
}
class Solution {
public:
    bool detectCapitalUse(string word) {
        int n = word.size();

        //if the first letter of the string is lower-case
        if(islower(word[0])){
            int c = 0;
            for(int i=0; i<n; i++){
                if(islower(word[i])){
                    c++;
                }
            }

            //total lower-case count must be equal to the size of the string
            if(c == n){
                return true;
            }
            return false;
        }

        //if the first letter of the string is upper-case.
        else{
            int c = 0;
            for(int i=0; i<n; i++){
                if(isupper(word[i])){
                    c++;
                }
            }

            //count of total upper-case letters must be equal to 1 or to the size of the string.
            if(c == 1 or c == n){
                return true;
            }

            //in all other cases, return false.
            return false;
        }
    }
};
var detectCapitalUse = function(word) {
      if((word.charAt(0)==word.charAt(0).toUpperCase() && word.slice(1)==word.slice(1).toLowerCase()) || (word == word.toUpperCase() 
   || word == word.toLowerCase()))
   {
      return true
   }
    else{
      return false
  }
};
Detect Capital