Simple python solution and easy to understand


  • 0
    L
    class Solution(object):
        def isStrobogrammatic(self, num):
            """
            :type num: str
            :rtype: bool
            """
            num_mapping={'0':'0','1':'1','6':'9','8':'8','9':'6'}
            reversed_num = ''
            for n in reversed(num):
                n = num_mapping.get(n, '')
                reversed_num += n
            return reversed_num == num
    

Log in to reply
 

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