| 7 | class Solution { |
| 8 | public: |
| 9 | bool detectCapitalUse(string word) { |
| 10 | bool all_caps = 1; |
| 11 | bool all_small = 1; |
| 12 | bool first_letter_caps = isupper(word[0]); |
| 13 | |
| 14 | for(int i=1; i<word.length() && (all_caps | all_small); i++) { |
| 15 | islower(word[i])? all_caps = 0: all_small = 0; |
| 16 | } |
| 17 | return (all_small | (first_letter_caps & all_caps)); |
| 18 | } |
| 19 | }; |