package leetcode;

/**
 * https://leetcode.com/problems/detect-capital/
 */
public class Problem520 {
    public boolean detectCapitalUse(String word) {

    }

    public static void main(String[] args) {
        Problem520 prob = new Problem520();
        System.out.println(prob.detectCapitalUse("USA")); // true
        System.out.println(prob.detectCapitalUse("leetcode")); // true
        System.out.println(prob.detectCapitalUse("Google")); // true
        System.out.println(prob.detectCapitalUse("ABc")); // false
        System.out.println(prob.detectCapitalUse("aBc")); // false
    }
}

@@ -150,241 +150,360 @@
 ) %7B%0A
-%0A
     
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem520 prob = new Problem520();%0A        System.out.println(prob.detectCapit
+if (word.length() == 1) %7B%0A            return true;%0A        %7D%0A        boolean allLowerCase = false;%0A        boolean allUpperCase = false;%0A        boolean pascalCase = f
 al
-U
 se
-(%22USA%22)); // true%0A        System.out.println(prob.detectCapitalUse(%22leetcode%22)); //
+;%0A        int i = 0;%0A        if (word.charAt(i) %3E= 'A' && word.charAt(i) %3C= 'Z' && word.charAt(i + 1) %3E= 'A' && word.charAt(i + 1) %3C= 'Z') %7B%0A            allUpperCase =
  true
+;
 %0A   
@@ -511,68 +511,157 @@
     
-System.out.println(prob.detectCapitalUse(%22Google%22)); //
+%7D else if (word.charAt(i) %3E= 'A' && word.charAt(i) %3C= 'Z' && word.charAt(i + 1) %3E= 'A' && word.charAt(i + 1) %3C= 'z') %7B%0A            pascalCase =
  true
+;
 %0A   
@@ -669,66 +669,248 @@
     
-System.out.println(prob.detectCapitalUse(%22ABc%22)); //
+%7D else %7B%0A            allLowerCase = true;%0A        %7D%0A        i++;%0A%0A        for (; i %3C word.length(); i++) %7B%0A            if (allUpperCase) %7B%0A                if (word.charAt(i) %3C 'A' %7C%7C word.charAt(i) %3E 'Z') %7B%0A                    return
  false
+;
 %0A   
@@ -918,66 +918,236 @@
     
-System.out.println(prob.detectCapitalUse(%22aBc%22)); // false
+        %7D%0A            %7D else %7B // all lower case or pascal case%0A                if (word.charAt(i) %3C 'a' %7C%7C word.charAt(i) %3E 'z') %7B%0A                    return false;%0A                %7D%0A            %7D%0A        %7D%0A        return true;
 %0A   

Solve problem 520