MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / detectCapitalUse

Method detectCapitalUse

C++/Detect-Capital.cpp:9–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7class Solution {
8public:
9 bool detectCapitalUse(string word) {
10 bool all_caps = 1;
11 bool all_small = 1;
12 bool first_letter_caps = isupper(word[0]);
13
14 for(int i=1; i<word.length() && (all_caps | all_small); i++) {
15 islower(word[i])? all_caps = 0: all_small = 0;
16 }
17 return (all_small | (first_letter_caps & all_caps));
18 }
19};

Callers

nothing calls this directly

Calls 1

lengthMethod · 0.80

Tested by

no test coverage detected