bool detectCapitalUse(string word) {
const char *c = word.c_str();
if (word.size() <= 1) return true;
if (*c <= 'z' && *c >= 'a') {
c = c + 1;
while (*c) {
if (*c <= 'Z' && *c >= 'A') return false;
c = c + 1;
}
} else {
c = c + 1;
if (*c <= 'Z' && *c >= 'A') {
c = c + 1;
while (*c) {
if (*c <= 'z' && *c >= 'a') return false;
c = c + 1;
}
} else {
c = c + 1;
while (*c) {
if (*c <= 'Z' && *c >= 'A') return false;
c = c + 1;
}
}
}
return true;
}

not use the counter, maybe complex.