Java Solution with Regex


  • 0
    C

    Very simple regex. Maybe there are more simple ones.

    public boolean detectCapitalUse(String word) {
            return word.matches("([A-Z]+)|([a-z]+)|([A-Z][a-z]+)");
        }
    

Log in to reply
 

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