Detect Capital

2017/12/4 posted in  leetcode

class Solution {
public:
    bool detectCapitalUse(string word) {
        int a[word.length()];
        int r = 0;
        for (int i = 0; i<word.length(); i++) {
            if (word[i]>='A'&&word[i]<='Z') {
                a[i] = 1;
                r+=a[i];
            }
        }
        if (r==word.length()||(a[0]==1&&r==1)||r==0) {
            return true;
        }
        return false;
    }
};