Skip to content

Commit 5f4e534

Browse files
authored
Create Readme.md
1 parent 3cc1d48 commit 5f4e534

File tree

1 file changed

+7
-0
lines changed
  • Stack/1673.Find-the-Most-Competitive-Subsequence

1 file changed

+7
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### 1673.Find-the-Most-Competitive-Subsequence
2+
3+
本题和```LC.402 Remove K Digits```一模一样,本质上就是求长度为k的最小序列。
4+
5+
我们维护一个递增的栈,一旦发现新数字a比栈顶元素b更小,我们肯定希望把这个a尽量前移(这样必然使得序列更小)。把a每前移一位,就意味着要舍弃栈顶的数字,直至已经被舍弃的数字总数达到上限。
6+
7+
当所有数字都入了栈,那么栈里面的就是最小的递增序列。当然,如果这个序列的数字数目大于了k,那么就舍弃最后的数字舍得剩下的恰好有k个。

0 commit comments

Comments
 (0)