Smallest number from an increase and decrease pattern
Given a pattern of I (increase) and D (decrease) characters of length n, build the smallest number of n + 1 distinct digits from 1 to 9 whose consecutive digits follow the pattern. Push digits onto a stack and pop them all whenever you see an I or reach the end.
No answer yet. Write the first one; the best answer gets endorsed.
