Java single line solution


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

Log in to reply
 

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