5 line Java Solution


  • 1
    H
        public boolean isStrobogrammatic(String num) {
            int [] arr = {0,1,0,0,0,0,9,0,8,6};
            StringBuilder sb = new StringBuilder();
            
            for(int i=num.length()-1;i>=0;i--)
                sb.append(arr[num.charAt(i)-'0']);            
            
            return num.equals(sb.toString());
        }
    

Log in to reply
 

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