Simple Java Solution, 31ms


  • 0
    H
    public class Solution {
        public boolean detectCapitalUse(String word) {
        	String str = word.substring(1);
            return Character.isUpperCase(word.charAt(0)) && str.equals(str.toUpperCase()) 
            		|| str.equals(str.toLowerCase());
        }
    }
    

Log in to reply
 

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