2 lines C++ clean code beats 94%


  • 0
    X
    class Solution {
    public:
        bool detectCapitalUse(string word) {
            int sum=accumulate(word.begin(),word.end(),0,[](int a,char b){ return a+(isupper(b)?1:0); });
            return word.size()==sum || 0==sum || (isupper(word[0])&&1==sum);
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.