1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-12 19:01:47 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (English)/出现频率最低的数字(English) [find-the-least-frequent-digit].html
2025-09-02 22:45:58 +08:00

36 lines
1.2 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>Given an integer <code>n</code>, find the digit that occurs <strong>least</strong> frequently in its decimal representation. If multiple digits have the same frequency, choose the <strong>smallest</strong> digit.</p>
<p>Return the chosen digit as an integer.</p>
The <strong>frequency</strong> of a digit <code>x</code> is the number of times it appears in the decimal representation of <code>n</code>.
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 1553322</span></p>
<p><strong>Output:</strong> 1</p>
<p><strong>Explanation:</strong></p>
<p>The least frequent digit in <code>n</code> is 1, which appears only once. All other digits appear twice.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 723344511</span></p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong></p>
<p>The least frequent digits in <code>n</code> are 7, 2, and 5; each appears only once.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 2<sup>31</sup> - 1</code></li>
</ul>