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)/好数对的数目 [number-of-good-pairs].html
2022-03-29 12:43:11 +08:00

36 lines
1004 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个整数数组 <code>nums</code></p>
<p>如果一组数字 <code>(i,j)</code> 满足 <code>nums[i]</code> == <code>nums[j]</code><code>i</code> &lt; <code>j</code> ,就可以认为这是一组 <strong>好数对</strong></p>
<p>返回好数对的数目。</p>
<p>&nbsp;</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>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 100</code></li>
<li><code>1 &lt;= nums[i] &lt;= 100</code></li>
</ul>