Leetcode: Numbers With Repeated Digits
作者:互联网
description
Given a positive integer N, return the number of positive integers less than or equal to N that have at least 1 repeated digit.
Example
Input: 1000
Output: 262
分析
- 这道题目中 testcase 有错误,所以真的不知道哪些 ac 的答案是怎么做到的? 犯错都是犯一样的错误~
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
总结
- 一道包含 错误 testcase 的dp 题目,枉我调试了好久好久~。 最关键的是还有那么多的 ac 答案
标签:Digits,count,ac,positive,262,Repeated,181,dup,Leetcode 来源: https://www.cnblogs.com/tmortred/p/13191433.html