mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
26 lines
768 B
HTML
26 lines
768 B
HTML
|
<p>购物车内的商品价格按照升序记录于数组 <code>price</code>。请在购物车中找到两个商品的价格总和刚好是 <code>target</code>。若存在多种情况,返回任一结果即可。</p>
|
|||
|
|
|||
|
<p><strong>示例 1:</strong></p>
|
|||
|
|
|||
|
<pre>
|
|||
|
<strong>输入:</strong>price = [3, 9, 12, 15], target = 18
|
|||
|
<strong>输出:</strong>[3,15] 或者 [15,3]
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>示例 2:</strong></p>
|
|||
|
|
|||
|
<pre>
|
|||
|
<strong>输入:</strong>price = [8, 21, 27, 34, 52, 66], target = 61
|
|||
|
<strong>输出:</strong>[27,34] 或者 [34,27]
|
|||
|
</pre>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>提示:</strong></p>
|
|||
|
|
|||
|
<ul>
|
|||
|
<li><code>1 <= price.length <= 10^5</code></li>
|
|||
|
<li><code>1 <= price[i] <= 10^6</code></li>
|
|||
|
<li><code>1 <= target <= 2*10^6</code></li>
|
|||
|
</ul>
|