Using a Robot to Print the Lexicographically Smallest String
Hold characters on a stack and print the top whenever it is no larger than every character still unread.
Hold characters on a stack and print the top whenever it is no larger than every character still unread.