1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/十-二进制数的最少数目 [partitioning-into-minimum-number-of-deci-binary-numbers].html
2022-03-29 12:43:11 +08:00

35 lines
1.1 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.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>如果一个十进制数字不含任何前导零,且每一位上的数字不是 <code>0</code> 就是 <code>1</code> ,那么该数字就是一个 <strong>十-二进制数</strong> 。例如,<code>101</code><code>1100</code> 都是 <strong>十-二进制数</strong>,而 <code>112</code><code>3001</code> 不是。</p>
<p>给你一个表示十进制整数的字符串 <code>n</code> ,返回和为 <code>n</code><strong>十-二进制数 </strong>的最少数目。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>n = "32"
<strong>输出:</strong>3
<strong>解释:</strong>10 + 11 + 11 = 32
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>n = "82734"
<strong>输出:</strong>8
</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输入:</strong>n = "27346209830709182346"
<strong>输出:</strong>9
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n.length &lt;= 10<sup>5</sup></code></li>
<li><code>n</code> 仅由数字组成</li>
<li><code>n</code> 不含任何前导零并总是表示正整数</li>
</ul>