1012. Numbers With Repeated Digits Hard

@problem@discussion
#Math#Dynamic Programming



1/**
2 * [1012] Numbers With Repeated Digits
3 *
4 * Given an integer n, return the number of positive integers in the range [1, n] that have at least one repeated digit.
5 *  
6 * Example 1:
7 * 
8 * Input: n = 20
9 * Output: 1
10 * Explanation: The only positive number (<= 20) with at least 1 repeated digit is 11.
11 * 
12 * Example 2:
13 * 
14 * Input: n = 100
15 * Output: 10
16 * Explanation: The positive numbers (<= 100) with atleast 1 repeated digit are 11, 22, 33, 44, 55, 66, 77, 88, 99, and 100.
17 * 
18 * Example 3:
19 * 
20 * Input: n = 1000
21 * Output: 262
22 * 
23 *  
24 * Constraints:
25 * 
26 * 	1 <= n <= 10^9
27 * 
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/numbers-with-repeated-digits/
32// discuss: https://leetcode.com/problems/numbers-with-repeated-digits/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37    pub fn num_dup_digits_at_most_n(n: i32) -> i32 {
38        0
39    }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46    use super::*;
47
48    #[test]
49    fn test_1012() {
50    }
51}
52


Back
© 2025 bowen.ge All Rights Reserved.