Simple Java Solution


  • 0
    V
    class Solution {
        public boolean detectCapitalUse(String word) 
        {
        		if (word.equals(word.toUpperCase()))
        		{
        			return true;
        		}
        		else if (word.equals(word.toLowerCase()))
        		{
        			return true;
        		}
        		else
        		{
        			String newString = word.substring(1, word.length());
        			
        			if (newString.equals(newString.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.