2022-01-24 Daily-Challenge
Today I have done leetcode's January LeetCoding Challenge with cpp
.
January LeetCoding Challenge 24
Description
Detect Capital
word
consists of lowercase and uppercase English letters.
Solution
class Solution {
public:
bool detectCapitalUse(string word) {
int count = 0;
for(auto c : word) {
count += !!isupper(c);
}
// int count = count_if(word.begin(), word.end(), isupper);
return count == word.length() || count == 0 || (count == 1 && isupper(word.front()));
}
};
// Accepted
// 550/550 cases passed (0 ms)
// Your runtime beats 100 % of cpp submissions
// Your memory usage beats 67.65 % of cpp submissions (6 MB)