text of lowercase English letters. Strike out some letters so that every letter that occurs in text is left exactly once. The remaining letters keep their order.
Among all possible results, return the lexicographically smallest one.text="dbcbad" → 'bcad'
We must keep one each of a, b, c and d. "bcad" can be obtained by striking letters out and is smaller than any other option: "abcd" is impossible because neither b nor c appears after the a.
text="zzaz" → 'az'
We can get "za" or "az"; the latter is smaller.
text="q" → 'q'
text consists of lowercase English letterstext="dbcbad"
'bcad'
Run checks the first 3 tests in your browser. Submit checks all 102 tests on the server, hidden ones included.