-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path520.cpp
More file actions
26 lines (24 loc) · 658 Bytes
/
Copy path520.cpp
File metadata and controls
26 lines (24 loc) · 658 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Solution {
public:
bool isBig(string& word, int i){
for(int k=i; k<word.size(); k++){
if(!(word[k] <='Z' && 'A'<=word[k]))
return false;
}
return true;
}
bool isSmall(string& word, int i){
for(int k=i; k<word.size(); k++){
if(!(word[k] <='z' && 'a'<=word[k]))
return false;
}
return true;
}
bool detectCapitalUse(string word) {
if(word.size()==0)
return true;
if(word[0] <='Z' && 'A'<=word[0])
return (isSmall(word,1) || isBig(word, 1));
return isSmall(word,1);
}
};