版权声明:本文为博主原创文章,请尊重原创,转载请注明原文地址和作者信息! https://blog.csdn.net/zzc15806/article/details/82555611
class Solution:
# 遍历
def isGood(self, n, s1, s2):
s = set([int(i) for i in str(n)])
return s.issubset(s2) and not s.issubset(s1)
def rotatedDigits(self, N):
"""
:type N: int
:rtype: int
"""
s1 = set([0, 1, 8])
s2 = set([0, 1, 2, 5, 6, 8, 9])
return sum(self.isGood(i, s1, s2) for i in range(1,N+1))