You're given a string s of lowercase letters, and you start with an empty holding stack and an empty output string.
You may repeat either move, in any order:
s off the front and push it onto the stack.Keep going until both s and the stack are empty. Return the lexicographically smallest output you can produce.
Input: s = "cab"
Output: "abc"
Load c and a, then emit a. Load b, then emit b and c.
Input: s = "bdab"
Output: "abdb"
To emit a first you have to load b, d and a. After emitting a, d is on top of the stack and blocks the b underneath, so "abbd" can't be produced.
Input: s = "dbca"
Output: "acbd"
Nothing can be emitted before a, so every character has to be loaded first. After that the stack only gives back c, b, d.
1 <= s.length <= 10^5s contains only lowercase English letters.