1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/查找总价格为目标值的两个商品 [he-wei-sde-liang-ge-shu-zi-lcof].html

26 lines
768 B
HTML
Raw Normal View History

2023-12-09 18:53:53 +08:00
<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>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= price.length &lt;= 10^5</code></li>
<li><code>1 &lt;= price[i] &lt;= 10^6</code></li>
<li><code>1 &lt;= target &lt;= 2*10^6</code></li>
</ul>