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)/两个数对之间的最大乘积差 [maximum-product-difference-between-two-pairs].html
2022-03-29 12:43:11 +08:00

37 lines
1.5 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>(a, b)</code><code>(c, d)</code> 之间的 <strong>乘积差</strong> 定义为 <code>(a * b) - (c * d)</code></p>
<ul>
<li>例如,<code>(5, 6)</code><code>(2, 7)</code> 之间的乘积差是 <code>(5 * 6) - (2 * 7) = 16</code></li>
</ul>
<p>给你一个整数数组 <code>nums</code> ,选出四个 <strong>不同的</strong> 下标 <code>w</code><code>x</code><code>y</code><code>z</code> ,使数对 <code>(nums[w], nums[x])</code><code>(nums[y], nums[z])</code> 之间的 <strong>乘积差</strong> 取到 <strong>最大值</strong></p>
<p>返回以这种方式取得的乘积差中的 <strong>最大值</strong></p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>nums = [5,6,2,7,4]
<strong>输出:</strong>34
<strong>解释:</strong>可以选出下标为 1 和 3 的元素构成第一个数对 (6, 7) 以及下标 2 和 4 构成第二个数对 (2, 4)
乘积差是 (6 * 7) - (2 * 4) = 34
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>nums = [4,2,5,9,7,4,8]
<strong>输出:</strong>64
<strong>解释:</strong>可以选出下标为 3 和 6 的元素构成第一个数对 (9, 8) 以及下标 1 和 5 构成第二个数对 (2, 4)
乘积差是 (9 * 8) - (2 * 4) = 64
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>4 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>4</sup></code></li>
</ul>