Steward
分享是一種喜悅、更是一種幸福
程式語言 - LeetCode - C++ - 520. Detect Capital
參考資訊:
https://github.com/doocs/leetcode/blob/main/solution/0500-0599/0520.Detect%20Capital/README_EN.md
題目:

解答:
class Solution {
public:
bool detectCapitalUse(string word) {
int cnt = count_if(word.begin(), word.end(), [](char c) { return isupper(c); } );
return cnt == 0 || cnt == word.size() || (cnt == 1 && isupper(word[0]));
}
};