A permutation perm of n integers of all the integers in the range [1, n] can be represented as a string s of length n - 1 where:
- s[i] == ‘I’ if perm[i] < perm[i + 1], and
- s[i] == ‘D’ if perm[i] > perm[i + 1].
Given a string s, reconstruct the lexicographically smallest permutation perm and return it.
c++
1 | class Solution { |