My 0ms easy solution


  • 0
    Y
    public boolean isStrobogrammatic(String num) {
        //0, 8, 1, 6-9
        for(int i = 0 ; i <= (num.length()-1)/2; i++){
            if(num.charAt(i) == '0' || num.charAt(i) == '8' 
                ||num.charAt(i) == '1'){
                    if(num.charAt(i) == num.charAt(num.length()-1-i))
                    continue;
            }else if(num.charAt(i) == '6' && num.charAt(num.length()-1-i) == '9'
                || num.charAt(i) == '9' && num.charAt(num.length()-1-i) == '6'){
                    continue;                    
            }
                return false;
    
        }
        return true;
    }

Log in to reply
 

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