mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
43 lines
1.2 KiB
HTML
43 lines
1.2 KiB
HTML
<p>给你一个 <strong>下标从 0 开始</strong> 的整数数组 <code>nums</code> ,返回满足下述条件的 <strong>不同</strong> 四元组 <code>(a, b, c, d)</code> 的 <strong>数目</strong> :</p>
|
||
|
||
<ul>
|
||
<li><code>nums[a] + nums[b] + nums[c] == nums[d]</code> ,且</li>
|
||
<li><code>a < b < c < d</code></li>
|
||
</ul>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>nums = [1,2,3,6]
|
||
<strong>输出:</strong>1
|
||
<strong>解释:</strong>满足要求的唯一一个四元组是 (0, 1, 2, 3) 因为 1 + 2 + 3 == 6 。
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>nums = [3,3,6,4,5]
|
||
<strong>输出:</strong>0
|
||
<strong>解释:</strong>[3,3,6,4,5] 中不存在满足要求的四元组。
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>nums = [1,1,1,3,5]
|
||
<strong>输出:</strong>4
|
||
<strong>解释:</strong>满足要求的 4 个四元组如下:
|
||
- (0, 1, 2, 3): 1 + 1 + 1 == 3
|
||
- (0, 1, 3, 4): 1 + 1 + 3 == 5
|
||
- (0, 2, 3, 4): 1 + 1 + 3 == 5
|
||
- (1, 2, 3, 4): 1 + 1 + 3 == 5
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>4 <= nums.length <= 50</code></li>
|
||
<li><code>1 <= nums[i] <= 100</code></li>
|
||
</ul>
|