public class Solution {
public boolean detectCapitalUse(String word) {
int count =
0;
String
str = word.toLowerCase();
for(
int i =
0; i < word.length();i++) {
if(
str.charAt(i) != word.charAt(i)) {
count++;
}
}
if(
count ==
0 ) {
return true;
}
else if(
count ==
1 && isCapital(word.charAt(
0))) {
return true;
}
else if(
count == word.length()) {
return true;
}
else {
return false;
}
}
public boolean isCapital(
char c) {
if (c>=
'A' && c<=
'Z') {
return true;
}
return false;
}
}
转载请注明原文地址: https://ju.6miu.com/read-25637.html