zoukankan      html  css  js  c++  java
  • Leetcode: 12012 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 答案
  • 相关阅读:
    JAVA多线程之AQS
    LRU算法
    JAVA设计之SPI
    JAVA多线程之CAS
    操作系统之中断处理
    计算机领域思想
    操作系统之I/O
    操作系统之虚拟内存
    Mysql事务原理
    Mysql添加索引
  • 原文地址:https://www.cnblogs.com/tmortred/p/13191433.html
Copyright © 2011-2022 走看看