We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1faa2c0 commit cd99329Copy full SHA for cd99329
0520-detect-capital/0520-detect-capital.cpp
@@ -0,0 +1,35 @@
1
+class Solution {
2
+public:
3
+ bool detectCapitalUse(string word) {
4
+
5
+ vector<string> ans;
6
7
+ stringstream ss(word);
8
+ string ok;
9
10
+ while(ss >> ok)
11
+ ans.push_back(ok);
12
13
+ for(auto itr : ans)
14
+ {
15
+ int caps = 0, small = 0, firstCaps = 0;
16
17
+ if(itr[0] >= 'A' and itr[0] <= 'Z')
18
+ firstCaps = 1;
19
+ for(auto x : itr)
20
21
+ if(x >= 'a' and x <= 'z')
22
+ ++small;
23
+ else
24
+ ++caps;
25
+ }
26
+ if(small == itr.size() or caps == itr.size() or (firstCaps == 1 and small == itr.size()-1))
27
28
29
30
31
+ return false;
32
33
+ return true;
34
35
+};
0 commit comments