Construct Smallest Number From DI String

Given a pattern string of 'I' (increasing) and 'D' (decreasing), construct the smallest number of length n+1 using digits 1 to n+1 where each digit is used exactly once.

Examples
Input: "IIIDIDDD"
Output: "123549876"
Hints

Construct Smallest Number From DI String

Given a pattern string of 'I' (increasing) and 'D' (decreasing), construct the smallest number of length n+1 using digits 1 to n+1 where each digit is used exactly once.