mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-22 05:26:46 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个下标从 <strong>0</strong> 开始的字符串 <code>text</code> 和另一个下标从 <strong>0</strong> 开始且长度为 <code>2</code> 的字符串 <code>pattern</code> ,两者都只包含小写英文字母。</p>\n\n<p>你可以在 <code>text</code> 中任意位置插入 <strong>一个</strong> 字符,这个插入的字符必须是 <code>pattern[0]</code> <b>或者</b> <code>pattern[1]</code> 。注意,这个字符可以插入在 <code>text</code> 开头或者结尾的位置。</p>\n\n<p>请你返回插入一个字符后,<code>text</code> 中最多包含多少个等于 <code>pattern</code> 的 <strong>子序列</strong> 。</p>\n\n<p><strong>子序列</strong> 指的是将一个字符串删除若干个字符后(也可以不删除),剩余字符保持原本顺序得到的字符串。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<b>输入:</b>text = \"abdcdbc\", pattern = \"ac\"\n<b>输出:</b>4\n<strong>解释:</strong>\n如果我们在 text[1] 和 text[2] 之间添加 pattern[0] = 'a' ,那么我们得到 \"ab<em><strong>a</strong></em>dcdbc\" 。那么 \"ac\" 作为子序列出现 4 次。\n其他得到 4 个 \"ac\" 子序列的方案还有 \"<em><strong>a</strong></em>abdcdbc\" 和 \"abd<em><strong>a</strong></em>cdbc\" 。\n但是,\"abdc<em><strong>a</strong></em>dbc\" ,\"abd<em><strong>c</strong></em>cdbc\" 和 \"abdcdbc<em><strong>c</strong></em>\" 这些字符串虽然是可行的插入方案,但是只出现了 3 次 \"ac\" 子序列,所以不是最优解。\n可以证明插入一个字符后,无法得到超过 4 个 \"ac\" 子序列。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>text = \"aabb\", pattern = \"ab\"\n<b>输出:</b>6\n<strong>解释:</strong>\n可以得到 6 个 \"ab\" 子序列的部分方案为 \"<em><strong>a</strong></em>aabb\" ,\"aa<em><strong>a</strong></em>bb\" 和 \"aab<em><strong>b</strong></em>b\" 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= text.length <= 10<sup>5</sup></code></li>\n\t<li><code>pattern.length == 2</code></li>\n\t<li><code>text</code> 和 <code>pattern</code> 都只包含小写英文字母。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 10,
|
||||
"likes": 11,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -149,7 +149,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"4.8K\", \"totalSubmission\": \"16.5K\", \"totalAcceptedRaw\": 4760, \"totalSubmissionRaw\": 16468, \"acRate\": \"28.9%\"}",
|
||||
"stats": "{\"totalAccepted\": \"4.8K\", \"totalSubmission\": \"16.6K\", \"totalAcceptedRaw\": 4821, \"totalSubmissionRaw\": 16625, \"acRate\": \"29.0%\"}",
|
||||
"hints": [
|
||||
"Find the optimal position to add pattern[0] so that the number of subsequences is maximized. Similarly, find the optimal position to add pattern[1].",
|
||||
"For each of the above cases, count the number of times the pattern occurs as a subsequence in text. The larger count is the required answer."
|
||||
|
Reference in New Issue
Block a user