Skip to content

Commit 43600f3

Browse files
committed
Runtime: 7 ms (Top 10.31%) | Memory: 6 MB (Top 66.23%)
1 parent 9863a46 commit 43600f3

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
1+
// Runtime: 7 ms (Top 10.31%) | Memory: 6 MB (Top 66.23%)
12
class Solution {
23
public:
34
bool detectCapitalUse(string word) {
45
int n = word.size();
5-
6-
//if the first letter of the string is lower-case
6+
7+
//if the first letter of the string is lower-case
78
if(islower(word[0])){
89
int c = 0;
910
for(int i=0; i<n; i++){
1011
if(islower(word[i])){
1112
c++;
1213
}
1314
}
14-
15-
//total lower-case count must be equal to the size of the string
15+
16+
//total lower-case count must be equal to the size of the string
1617
if(c == n){
1718
return true;
1819
}
1920
return false;
2021
}
21-
22-
//if the first letter of the string is upper-case.
22+
23+
//if the first letter of the string is upper-case.
2324
else{
2425
int c = 0;
2526
for(int i=0; i<n; i++){
2627
if(isupper(word[i])){
2728
c++;
2829
}
2930
}
30-
31-
//count of total upper-case letters must be equal to 1 or to the size of the string.
31+
32+
//count of total upper-case letters must be equal to 1 or to the size of the string.
3233
if(c == 1 or c == n){
3334
return true;
3435
}
35-
36-
//in all other cases, return false.
36+
37+
//in all other cases, return false.
3738
return false;
3839
}
3940
}
40-
};
41+
};

0 commit comments

Comments
 (0)