3 lines of C++ solution


  • 0
    W

    class Solution {
    public:
    bool detectCapitalUse(string word) {
    int count=0;
    for(auto c:word)count+=(c<='Z');
    return !count||count==1&&word[0]<='Z'||count==word.size();
    }
    };


Log in to reply
 

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