easy understand python solution without math trick


  • 0

    '''
    class Solution(object):
    def isStrobogrammatic(self, num):
    """
    :type num: str
    :rtype: bool
    """

        pair = {'6':'9', '9':'6', '1':'1', '0':'0', '8':'8'}
        
    
        for i in range(0, (len(num)//2) + 1):
            if num[i] in pair:
                if num[len(num) - 1 - i] != pair[num[i]]:
                    return False
            else:
                return False
        return True
    

    '''


Log in to reply
 

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