forked from larissalages/code_problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path520.cpp
More file actions
47 lines (47 loc) · 1009 Bytes
/
520.cpp
File metadata and controls
47 lines (47 loc) · 1009 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class Solution {
public:
bool detectCapitalUse(string word) {
bool upper=true,lower=true;
if(word[0]-'A'>=0&&word[0]-'A'<26)
{
for(int i=1;i<word.size();i++)
{
if(word[i]-'a'>=0&&word[i]-'a'<26)
{
continue;
}
else{
lower=false;
break;
}
}
for(int i=1;i<word.size();i++)
{
if(word[i]-'A'>=0&&word[i]-'A'<26)
{
continue;
}
else{
upper=false;
break;
}
}
}
else{
upper=false;
for(int i=1;i<word.size();i++)
{
if(word[i]-'a'>=0&&word[i]-'a'<26)
{
continue;
}
else{
lower=false;
break;
}
}
}
bool ans=upper|lower;
return ans;
}
};