3747. Count Distinct Integers After Removing Zeros Medium
1/**
2 * [3747] Count Distinct Integers After Removing Zeros
3 *
4 * You are given a positive integer n.
5 * For every integer x from 1 to n, we write down the integer obtained by removing all zeros from the decimal representation of x.
6 * Return an integer denoting the number of distinct integers written down.
7 *
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">n = 10</span>
11 * Output: <span class="example-io">9</span>
12 * Explanation:
13 * The integers we wrote down are 1, 2, 3, 4, 5, 6, 7, 8, 9, 1. There are 9 distinct integers (1, 2, 3, 4, 5, 6, 7, 8, 9).
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">n = 3</span>
18 * Output: <span class="example-io">3</span>
19 * Explanation:
20 * The integers we wrote down are 1, 2, 3. There are 3 distinct integers (1, 2, 3).
21 * </div>
22 *
23 * Constraints:
24 *
25 * 1 <= n <= 10^15
26 *
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/count-distinct-integers-after-removing-zeros/
31// discuss: https://leetcode.com/problems/count-distinct-integers-after-removing-zeros/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36 pub fn count_distinct(n: i64) -> i64 {
37
38 }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_3747() {
49 }
50}
51Back
© 2026 bowen.ge All Rights Reserved.