A battalion's radio callsigns must follow one of exactly three approved capitalization styles: entirely uppercase (such as "GHOST"), entirely lowercase (such as "ghost"), or capitalized with only the first letter uppercase and every other letter lowercase (such as "Ghost"). Any other mix of cases is a violation of case discipline. You are handed a single callsign and must decide whether it complies.
A single line containing a string s consisting only of uppercase and lowercase English letters (no digits, spaces, or punctuation).
Print VALID if s follows one of the three approved capitalization styles described above, or INVALID otherwise.
Example 1
Input
GHOST
Expected
VALID
Explanation
Every letter is uppercase, which matches the all-uppercase style, so the callsign is VALID.
Example 2
Input
gHost
Expected
INVALID
Explanation
The word starts with a lowercase 'g' but contains an uppercase 'H' later. It is not all-uppercase, not all-lowercase, and does not have only its first letter capitalized, so none of the three approved styles match and the callsign is INVALID.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →