mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
36 lines
1004 B
HTML
36 lines
1004 B
HTML
<p>给你一个整数数组 <code>nums</code> 。</p>
|
||
|
||
<p>如果一组数字 <code>(i,j)</code> 满足 <code>nums[i]</code> == <code>nums[j]</code> 且 <code>i</code> < <code>j</code> ,就可以认为这是一组 <strong>好数对</strong> 。</p>
|
||
|
||
<p>返回好数对的数目。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>nums = [1,2,3,1,1,3]
|
||
<strong>输出:</strong>4
|
||
<strong>解释:</strong>有 4 组好数对,分别是 (0,3), (0,4), (3,4), (2,5) ,下标从 0 开始
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>nums = [1,1,1,1]
|
||
<strong>输出:</strong>6
|
||
<strong>解释:</strong>数组中的每组数字都是好数对</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>nums = [1,2,3]
|
||
<strong>输出:</strong>0
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= nums.length <= 100</code></li>
|
||
<li><code>1 <= nums[i] <= 100</code></li>
|
||
</ul>
|