Share my AC solution


  • 1
    S
    public boolean detectCapitalUse(String word) {
    	if (word.equals(word.toUpperCase())) return true;
    	else if (word.equals(word.toLowerCase())) return true;
    	if (word.charAt(0)- 'A'>=0 && word.charAt(0)- 'A'<26){
    		String resString = word.substring(1);
    		if (resString.equals(resString.toLowerCase()))return true;
    	}
    	return false;
    }
    

Log in to reply
 

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