未验证 提交 4d83745f 编写于 作者: K KEQI HUANG 提交者: GitHub

Update 316._Remove_Duplicate_Letters.md

上级 b551d02c
......@@ -34,13 +34,13 @@ class Solution(object):
remaining = collections.defaultdict(int)
for c in s:
remaining[c] += 1
stack, res = set(), []
res, stack = [], set()
for c in s:
if c not in stack:
while res and res[-1] > c and remaining[res[-1]] > 0:
stack.remove(res.pop())
res.append(c)
stack.add(c)
res += c
remaining[c] -= 1
return ''.join(res)
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册