Skip to content

Commit 9b2490a

Browse files
author
lucifer
committed
feat: typo
1 parent 5c98c47 commit 9b2490a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

problems/1332.remove-palindromic-subsequences.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ s 仅包含字母 'a'  和 'b'
5757

5858
这又是一道“抖机灵”的题目,类似的题目有[1297.maximum-number-of-occurrences-of-a-substring](https://github.com/azl397985856/leetcode/blob/77db8fa47c7ee0a14b320f7c2d22f7c61ae53c35/problems/1297.maximum-number-of-occurrences-of-a-substring.md)
5959

60-
由于只有 a 和 b 两个字符。其实最多的消除次数就是 2。因为我们无论如何都可以先消除全部的 1 再消除全部的 2(先消除 2 也一样),这样只需要两次即可完成。 我们再看一下题目给的一次消除的情况,题目给的例子是“ababa”,我们发现其实它本身就是一个回文串,所以才可以一次全部消除。那么思路就有了:
60+
由于只有 a 和 b 两个字符。其实最多的消除次数就是 2。这是因为每次我们可以消除一个子序列,而不是消除一个子串。这样我们就可以可以先消除全部的 1 再消除全部的 2(先消除 2 也一样),这样只需要两次即可完成。 有可能 0 次或者 1 次么?有的。
61+
62+
比如题目给的一次消除的情况,题目给的例子是“ababa”,我们发现其实它本身就是一个回文串,所以才可以一次全部消除。那么思路就有了:
6163

6264
- 如果 s 是回文,则我们需要一次消除
6365
- 否则需要两次

problems/22.generate-parentheses.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def dfs(l, r, s):
5555
if l > n or r > n: return
5656
if (l == r == n): res.append(s)
5757
# 剪枝,提高算法效率
58-
if l > r: return
58+
if l < r: return
5959
# 加一个左括号
6060
dfs(l + 1, r, s + '(')
6161
# 加一个右括号

0 commit comments

Comments
 (0)