1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-07 00:11:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你一个整数数组&nbsp;<code>nums</code>&nbsp;和一个整数&nbsp;<code>k</code>&nbsp;,请你返回数对&nbsp;<code>(i, j)</code>&nbsp;的数目,满足&nbsp;<code>i &lt; j</code>&nbsp;且&nbsp;<code>|nums[i] - nums[j]| == k</code>&nbsp;。</p>\n\n<p><code>|x|</code>&nbsp;的值定义为:</p>\n\n<ul>\n\t<li>如果&nbsp;<code>x &gt;= 0</code>&nbsp;,那么值为&nbsp;<code>x</code>&nbsp;。</li>\n\t<li>如果&nbsp;<code>x &lt; 0</code>&nbsp;,那么值为&nbsp;<code>-x</code>&nbsp;。</li>\n</ul>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre><b>输入:</b>nums = [1,2,2,1], k = 1\n<b>输出:</b>4\n<b>解释:</b>差的绝对值为 1 的数对为:\n- [<em><strong>1</strong></em>,<em><strong>2</strong></em>,2,1]\n- [<em><strong>1</strong></em>,2,<em><strong>2</strong></em>,1]\n- [1,<em><strong>2</strong></em>,2,<em><strong>1</strong></em>]\n- [1,2,<em><strong>2</strong></em>,<em><strong>1</strong></em>]\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre><b>输入:</b>nums = [1,3], k = 3\n<b>输出:</b>0\n<b>解释:</b>没有任何数对差的绝对值为 3 。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre><b>输入:</b>nums = [3,2,1,5,4], k = 2\n<b>输出:</b>3\n<b>解释:</b>差的绝对值为 2 的数对为:\n- [<em><strong>3</strong></em>,2,<em><strong>1</strong></em>,5,4]\n- [<em><strong>3</strong></em>,2,1,<em><strong>5</strong></em>,4]\n- [3,<em><strong>2</strong></em>,1,5,<em><strong>4</strong></em>]\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= nums.length &lt;= 200</code></li>\n\t<li><code>1 &lt;= nums[i] &lt;= 100</code></li>\n\t<li><code>1 &lt;= k &lt;= 99</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 69,
"likes": 71,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"42.4K\", \"totalSubmission\": \"49.5K\", \"totalAcceptedRaw\": 42375, \"totalSubmissionRaw\": 49468, \"acRate\": \"85.7%\"}",
"stats": "{\"totalAccepted\": \"43.5K\", \"totalSubmission\": \"50.9K\", \"totalAcceptedRaw\": 43503, \"totalSubmissionRaw\": 50859, \"acRate\": \"85.5%\"}",
"hints": [
"Can we check every possible pair?",
"Can we use a nested for loop to solve this problem?"