Clear python solution

  • 0
    def isStrobogrammatic(self, num):
        acceptable = ['1','6','9','8','0']
        counter = {}
        for c in acceptable:
            if c is '6':
                counter[c] = '9'
            elif c is '9':
                counter[c] = '6'
                counter[c] = c
        for i in range(len(num)):
            if num[i] in counter:
                if num[len(num)-i-1] != counter[num[i]]:
                    return False
                return False
        return True

Log in to reply

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