1056. Confusing Number (Easy) - TengnanYao/daily_leetcode GitHub Wiki
class Solution:
def confusingNumber(self, n: int) -> bool:
s = str(n)
n = len(s)
r = ""
for c in s:
if c in "23457":
return False
if c == "6":
r = "9" + r
elif c == "9":
r = "6" + r
else:
r = c + r
return r != s