text made of lowercase English letters and stars *. The stars must be removed one at a time from left to right: each star is erased together with one letter to its left, and that letter must be the alphabetically smallest of the letters still remaining to its left.
If there are several copies of that smallest letter, you may erase any one of them. Choose so that the final string (once all stars are gone) is as small as possible in lexicographic order, and return it.
It is guaranteed that every star still has at least one letter to its left when its turn comes.text="bcab*" → 'bcb'
The star erases the smallest letter to its left, which is a, leaving bcb.
text="cac*a*" → 'cc'
The first star erases the only a before it, giving cca*. The second star erases the new a, leaving cc.
text="dd*e" → 'de'
Both d letters are the same, and erasing either one gives de.
text consists of lowercase English letters and *text="bcab*"
'bcb'
Run checks the first 3 tests in your browser. Submit checks all 67 tests on the server, hidden ones included.