标签:git dup 运行 script tco 总结 number ted 错误
Given a positive integer N, return the number of positive integers less than or equal to N that have at least 1 repeated digit.
Input: 1000
Output: 262
count = 0
dup = [‘00‘, ‘11‘, ‘22‘, ‘33‘, ‘44‘, ‘55‘, ‘66‘, ‘77‘, ‘88‘, ‘99‘]
for i in range(1, 1001):
s = str(i)
for j in dup:
if j in s:
count += 1
break
print(count) ==> 181
运行这段代码可以看出 小于等于 1000 的整个数是 181, 不是 262
Leetcode: Numbers With Repeated Digits
标签:git dup 运行 script tco 总结 number ted 错误
原文地址:https://www.cnblogs.com/tmortred/p/13191433.html