class Solution {
public:
bool detectCapitalUse(string word) {
int a[word.length()];
int r = 0;
for (int i = 0; i<word.length(); i++) {
if (word[i]>='A'&&word[i]<='Z') {
a[i] = 1;
r+=a[i];
}
}
if (r==word.length()||(a[0]==1&&r==1)||r==0) {
return true;
}
return false;
}
};
Detect Capital
Copyright © 2017 Powered by LZH, Theme used GitHub CSS.