1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-05 15:31:43 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (English)/两个数字的最大乘积(English) [maximum-product-of-two-digits].html
2025-05-15 01:05:54 +08:00

62 lines
1.8 KiB
HTML

<p>You are given a positive integer <code>n</code>.</p>
<p>Return the <strong>maximum</strong> product of any two digits in <code>n</code>.</p>
<p><strong>Note:</strong> You may use the <strong>same</strong> digit twice if it appears more than once in <code>n</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 31</span></p>
<p><strong>Output:</strong> <span class="example-io">3</span></p>
<p><strong>Explanation:</strong></p>
<ul>
<li>The digits of <code>n</code> are <code>[3, 1]</code>.</li>
<li>The possible products of any two digits are: <code>3 * 1 = 3</code>.</li>
<li>The maximum product is 3.</li>
</ul>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 22</span></p>
<p><strong>Output:</strong> <span class="example-io">4</span></p>
<p><strong>Explanation:</strong></p>
<ul>
<li>The digits of <code>n</code> are <code>[2, 2]</code>.</li>
<li>The possible products of any two digits are: <code>2 * 2 = 4</code>.</li>
<li>The maximum product is 4.</li>
</ul>
</div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 124</span></p>
<p><strong>Output:</strong> <span class="example-io">8</span></p>
<p><strong>Explanation:</strong></p>
<ul>
<li>The digits of <code>n</code> are <code>[1, 2, 4]</code>.</li>
<li>The possible products of any two digits are: <code>1 * 2 = 2</code>, <code>1 * 4 = 4</code>, <code>2 * 4 = 8</code>.</li>
<li>The maximum product is 8.</li>
</ul>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>10 &lt;= n &lt;= 10<sup>9</sup></code></li>
</ul>