Given a pattern containing only I
s and D
s, I
for increasing and D
for decreasing, devise an algorithm to print the minimum number following that pattern.
Digits are 1..9
and can’t repeat.
"D"
should return 21
.
"I"
should return 12
.
"DD"
should return 321
.
"II"
should return 123
.
"DIDI"
should return 21435
.