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)/统计特殊四元组 [count-special-quadruplets].html

43 lines
1.2 KiB
HTML
Raw Normal View History

2022-03-27 20:38:29 +08:00
<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 &lt; b &lt; c &lt; d</code></li>
</ul>
<p>&nbsp;</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>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>4 &lt;= nums.length &lt;= 50</code></li>
<li><code>1 &lt;= nums[i] &lt;= 100</code></li>
</ul>