520. 检测大写字母
class Solution {
public:
bool detectCapitalUse(string word) {
int big = 0, small = 0, len = word.length();
for (int i = 0; i < len; i++) {
if (word[i] >= 65 && word[i] <= 90) {
big++;
}
else {
small++;
}
}
if (big == len || small == len) {
return true;
}
else if (len > 1 && big == 1) {
if (word[0] <= 90) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
};