1# Runtime: 226 ms (Top 14.46%) | Memory: 13.9 MB (Top 71.45%)2class Solution:3def rotatedDigits(self, n: int) -> int:4d = {0: 0, 1: 1, 2: 5, 3: None, 4: None, 5: 2, 6: 9, 7: None, 8: 8, 9: 6}5res = 06for i in range(n + 1):7t = i8pos = 09temp = 010status = True11while t > 0:12r = d[13t % 1014] # Every Digit Rotation Is Must, We Don't Have Choice To Leave It Without Rotating15if r is None:16status = False17break1819temp += (10**pos) * r20pos += 121t = t // 102223if temp != i and status:24res += 125return res