forked from wisdompeak/LeetCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9338ba1
commit 13f2082
Showing
1 changed file
with
5 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
Stack/2030.Smallest-K-Length-Subsequence-With-Occurrences-of-a-Letter/Readme.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### 2030.Smallest-K-Length-Subsequence-With-Occurrences-of-a-Letter | ||
|
||
本题本质和```402.Remove-K-Digits```差不多。只不过多在单调栈的维护递增序列的过程中需要注意两个条件:1. 删除的字符总数不能超过k0,即```s.size()-k```;并且删除的letter数目不能超过k1,即letter出现的总频次减去repetition. | ||
|
||
我们用单调栈构建了一个递增序列之后,可能它的长度太长,即删减的字符不够多。此时我们必须继续从尾部开始删字符。删除尾部的操作同样延续之前的两个条件:1. 删除的字符总数不能超过k0;2. 删除的letter数目不能超过k1。如果不能删除,就保留该字符,处理下一个。 |