Simple java solution


  • 2
    V
    public class Solution {
        public boolean isStrobogrammatic(String num) {
            int low = 0, high = num.length() - 1;
            while(low <= high){
                int clow = num.charAt(low) - '0';
                int chigh = num.charAt(high) - '0';
                if(((2 <= clow && clow <= 5) || clow == 7) || ((2 <= chigh && chigh <= 5) || chigh == 7)){
                    return false;
                } else{
                    if(clow == 6){
                        if(chigh !=9) return false;
                    } else if(clow == 9){
                        if(chigh != 6) return false;
                    } else{
                        if(clow != chigh) return false;
                    }
                }
                low++; high--;
                
            }
            return true;
        }
    }

Log in to reply
 

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