0ms Java solution


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

Log in to reply
 

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