22: Detect capital

Given a non-empty string, write a method to check if the spelling correct

The spelling is correct if:

  • All letters are capital. Example: ABC
  • All letters are lower case. Example: abc
  • Only the first letter is capital, all others are lower case. Example: Abc

 

Example 1

Input:  Bazinga

Output: true

Example 1

Input:  CoDe

Output: false