Created
August 2, 2020 08:57
-
-
Save tafo/4831b78586e741bf15de964996b2297e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool DetectCapitalUse(string word) | |
{ | |
if (word.Length == 1) return true; | |
if (word[0] <= 'Z' && word[1] <= 'Z') | |
{ | |
for (var i = 2; i < word.Length; i++) | |
{ | |
if (word[i] <= 'Z') continue; | |
return false; | |
} | |
} | |
else | |
{ | |
if (word[1] <= 'Z') return false; | |
for (var i = 2; i < word.Length; i++) | |
{ | |
if (word[i] >= 'a') continue; | |
return false; | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment