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)/最小和分割 [split-with-minimum-sum].html

47 lines
1.6 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

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>给你一个正整数&nbsp;<code>num</code>&nbsp;,请你将它分割成两个非负整数&nbsp;<code>num1</code>&nbsp;<code>num2</code>&nbsp;,满足:</p>
<ul>
<li><code>num1</code>&nbsp;<code>num2</code>&nbsp;直接连起来,得到&nbsp;<code>num</code>&nbsp;各数位的一个排列。
<ul>
<li>换句话说,<code>num1</code>&nbsp;<code>num2</code>&nbsp;中所有数字出现的次数之和等于&nbsp;<code>num</code>&nbsp;中所有数字出现的次数。</li>
</ul>
</li>
<li><code>num1</code>&nbsp;<code>num2</code>&nbsp;可以包含前导 0 。</li>
</ul>
<p>请你返回&nbsp;<code>num1</code><code>num2</code>&nbsp;可以得到的和的 <strong>最小</strong> 值。</p>
<p><strong>注意:</strong></p>
<ul>
<li><code>num</code>&nbsp;保证没有前导 0 。</li>
<li><code>num1</code>&nbsp;<code>num2</code>&nbsp;中数位顺序可以与&nbsp;<code>num</code>&nbsp;中数位顺序不同。</li>
</ul>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<b>输入:</b>num = 4325
<b>输出:</b>59
<b>解释:</b>我们可以将 4325 分割成 <code>num1 </code>= 24 和 <code>num2 </code>= 35 ,和为 59 59 是最小和。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<b>输入:</b>num = 687
<b>输出:</b>75
<b>解释:</b>我们可以将 687 分割成 <code>num1</code> = 68 和 <code>num2 </code>= 7 ,和为最优值 75 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>10 &lt;= num &lt;= 10<sup>9</sup></code></li>
</ul>