Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def rotatedDigits(self, N: int) -> int:
- rotations = {
- '0': 1,
- '1': 1,
- '8': 1,
- '2': 1,
- '5': 1,
- '6': 1,
- '9': 1,
- }
- count = 0
- skip = False
- for i in range(N, 1):
- n = str(i)
- for j in n:
- try:
- rotations[i]
- except KeyError:
- skip = True
- continue
- if not skip:
- count += 1
- skip = False
- return count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement