Skip to content

LC 0246 [E] Strobogrammatic Number

Code with Senpai edited this page Aug 4, 2022 · 3 revisions
class Solution:
    def isStrobogrammatic(self, s: str) -> bool:
        if not s: 
            return False
        
        pairs = set([('0','0'), ('1','1'), ('6','9'), ('8','8'), ('9','6')])

        l, r = 0, len(s) - 1        
        while l <= r:
            if (s[l], s[r]) not in pairs:
                return False
            l += 1 ; r -= 1
        return True
Clone this wiki locally