Python Readable 1-liner


  • 0
    M
        def isStrobogrammatic(self, num):
            """
            :type num: str
            :rtype: bool
            """
            flipped = {
                '0': '0',
                '1': '1', 
                '2': '', 
                '3': '',
                '4': '',
                '5': '',
                '6': '9',
                '7': '',
                '8': '8',
                '9': '6'
            }
            
            return ''.join(reversed([flipped[n] for n in num])) == num
    

Log in to reply
 

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