Java 0ms 5-line solution without using HashMap

  • 1
    public boolean isStrobogrammatic(String num) {
        int[] map = new int[10];
        int lo = 0, hi = num.length()-1;
        while(lo<=hi) if(num.charAt(hi--)-'0' != map[num.charAt(lo++)-'0']) return false;
        return true;

  • 0

    very smart solution.

Log in to reply

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