Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update problem description #681

Merged
merged 1 commit into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions solution/1300-1399/1332.Remove Palindromic Subsequences/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,19 @@
先删除回文子序列 "baab",然后再删除 "b"。
</pre>

<p><strong>示例 4:</strong></p>

<pre><strong>输入:</strong>s = &quot;&quot;
<strong>输出:</strong>0
</pre>

<p>&nbsp;</p>

<p><strong>提示:</strong></p>

<ul>
<li><code>0 &lt;= s.length &lt;= 1000</code></li>
<li><code>s</code> 仅包含字母&nbsp;&#39;a&#39;&nbsp; 和 &#39;b&#39;</li>
</ul>
- `1 <= s.length <= 1000`
- `s` 仅包含字母 `'a'` 和 `'b'`

## 解法

<!-- 这里可写通用的实现逻辑 -->

- 如果字符串 s 是个空串,直接返回 0。
- 如果字符串 s 本身是个回文串,那么只需要删除 1 次。
- 如果字符串 s 不是个回文串,我们注意到 s 最多只有两种字母 "a", "b",并且删除的是一个子序列,因此可以先删除所有字母 "a" (`"aaa...aaa"` 是个回文串),再删除所有字母 "b",即可使得字符串变为空。因此需要的删除次数是 2 次。
- 如果字符串 s 本身是个回文串,那么只需要删除 1 次。
- 如果字符串 s 不是个回文串,我们注意到 s 最多只有两种字母 "a", "b",并且删除的是一个子序列,因此可以先删除所有字母 "a" (`"aaa...aaa"` 是个回文串),再删除所有字母 "b",即可使得字符串变为空。因此需要的删除次数是 2 次。

<!-- tabs:start -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ Remove palindromic subsequence &quot;baab&quot; then &quot;b&quot;.
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= s.length &lt;= 1000</code></li>
<li><code>s[i]</code> is either <code>&#39;a&#39;</code> or <code>&#39;b&#39;</code>.</li>
</ul>
- `1 <= s.length <= 1000`
- `s` is either `'a'` or `'b'`

## Solutions

Expand Down