Problem 2375 · Medium

Construct Smallest Number From DI String

Push digits in order and pop a run of them only when the pattern says increase, which gives the smallest permutation that fits.

Open the interactive visualisation