mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-12-20 02:44:59 +08:00
38 lines
1.2 KiB
HTML
38 lines
1.2 KiB
HTML
<p>You are given a <strong>positive</strong> integer <code>n</code>.</p>
|
|
|
|
<p>For every integer <code>x</code> from 1 to <code>n</code>, we write down the integer obtained by removing all zeros from the decimal representation of <code>x</code>.</p>
|
|
|
|
<p>Return an integer denoting the number of <strong>distinct</strong> integers written down.</p>
|
|
|
|
<p> </p>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io">n = 10</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io">9</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>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).</p>
|
|
</div>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io">n = 3</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io">3</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>The integers we wrote down are 1, 2, 3. There are 3 distinct integers (1, 2, 3).</p>
|
|
</div>
|
|
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= n <= 10<sup>15</sup></code></li>
|
|
</ul>
|