Construct Smallest Number From DI String

Given a pattern string containing only I and D, construct the lexicographically smallest string formed from the digits 1 through pattern.length + 1, using every digit exactly once. For every index i, I requires the digit at i to be less than the digit at i + 1, and D requires it to be greater.

Examples
Input: "I"
Output: "12"
Hints

Construct Smallest Number From DI String

Given a pattern string containing only `I` and `D`, construct the lexicographically smallest string formed from the digits `1` through `pattern.length + 1`, using every digit exactly once. For every index `i`, `I` requires the digit at `i` to be less than the digit at `i + 1`, and `D` requires it to be greater.