This question is asked by Google. Given a string, return whether or not it uses capitalization correctly. A string correctly uses capitalization if all letters are capitalized, no letters are capitalized, or only the first letter is capitalized.

"USA", return true
"Calvin", return true
"compUter", return false
"coding", return true

🗣️ Discussion

In C#, you can use the IsUpper() method to see if a character is uppercase. This method indicates whether or not a certain character is uppercase.

🎯 Solution

public static bool CorrectCapitalization(string moves) {
		int count= 0;
    	foreach(char i in moves.ToCharArray()){
			if(Char.IsUpper(i)){
				count ++;
			}
		}
		if(count ==1 && Char.IsUpper(moves[0]))
			return true;
		return count == moves.Length;
    }