clear java solution


  • 0
    K
    public boolean isStrobogrammatic(String num) {
    	StringBuilder sb = new StringBuilder();
    	for (char c:num.toCharArray())
    	switch (c) { 
    		case '2':case '3':case '4':case '5':case '7':return false;
    		case '6':sb.insert(0,'9');break;
    		case '9':sb.insert(0,'6');break;
    		default: sb.insert(0,c);
    	}
    	return sb.toString().equals(num);
        }
    

Log in to reply
 

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