1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-02 22:13:28 +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>给你一个整数数组 <code>arr</code> 和一个整数 <code>difference</code>,请你找出并返回 <code>arr</code> 中最长等差子序列的长度,该子序列中相邻元素之间的差等于 <code>difference</code> 。</p>\n\n<p><strong>子序列</strong> 是指在不改变其余元素顺序的情况下,通过删除一些元素或不删除任何元素而从 <code>arr</code> 派生出来的序列。</p>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>arr = [1,2,3,4], difference = 1\n<strong>输出:</strong>4\n<strong>解释:</strong>最长的等差子序列是 [1,2,3,4]。</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>arr = [1,3,5,7], difference = 1\n<strong>输出:</strong>1\n<strong>解释:</strong>最长的等差子序列是任意单个元素。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<strong>输入:</strong>arr = [1,5,7,8,5,3,4,2,1], difference = -2\n<strong>输出:</strong>4\n<strong>解释:</strong>最长的等差子序列是 [7,5,3,1]。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= arr.length <= 10<sup>5</sup></code></li>\n\t<li><code>-10<sup>4</sup> <= arr[i], difference <= 10<sup>4</sup></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 211,
"likes": 213,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"38.5K\", \"totalSubmission\": \"74.8K\", \"totalAcceptedRaw\": 38536, \"totalSubmissionRaw\": 74829, \"acRate\": \"51.5%\"}",
"stats": "{\"totalAccepted\": \"39K\", \"totalSubmission\": \"75.7K\", \"totalAcceptedRaw\": 39007, \"totalSubmissionRaw\": 75735, \"acRate\": \"51.5%\"}",
"hints": [
"Use dynamic programming.",
"Let dp[i] be the maximum length of a subsequence of the given difference whose last element is i.",