Smallest number from an increase and decrease pattern

0
Remix

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.

AirbnbTechnical phone screenLast asked Feb 2026
No answer yet. Write the first one; the best answer gets endorsed.