#3816

Lexicographically Smallest String After Deleting Duplicate Characters

grandmaster · 2220 · lc hard +32 · 19.4% accepted · 41 likes · top 1%

Description

Given a string s of lowercase English letters, repeatedly pick any character that still has a duplicate in s and remove one copy of it (you may do this any number of times, including zero). Return the lexicographically smallest string achievable.

Code

1
2
3