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)/四数之和 [4sum].html

36 lines
1.2 KiB
HTML
Raw Normal View History

2022-03-27 20:56:26 +08:00
<p>给你一个由 <code>n</code> 个整数组成的数组&nbsp;<code>nums</code> ,和一个目标值 <code>target</code> 。请你找出并返回满足下述全部条件且<strong>不重复</strong>的四元组&nbsp;<code>[nums[a], nums[b], nums[c], nums[d]]</code>&nbsp;(若两个四元组元素一一对应,则认为两个四元组重复):</p>
<ul>
<li><code>0 &lt;= a, b, c, d&nbsp;&lt; n</code></li>
<li><code>a</code><code>b</code><code>c</code><code>d</code> <strong>互不相同</strong></li>
<li><code>nums[a] + nums[b] + nums[c] + nums[d] == target</code></li>
</ul>
<p>你可以按 <strong>任意顺序</strong> 返回答案 。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [1,0,-1,0,-2,2], target = 0
<strong>输出:</strong>[[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]]
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [2,2,2,2,2], target = 8
<strong>输出:</strong>[[2,2,2,2]]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 200</code></li>
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
<li><code>-10<sup>9</sup> &lt;= target &lt;= 10<sup>9</sup></code></li>
</ul>