The signature of a permutation is a string that is computed as follows: for each pair of consecutive elements of the permutation, write down the letter 'I' (increasing) if the second element is greater than the first one, otherwise write down the letter 'D' (decreasing).
For example, the signature of the permutation {3,1,2,7,4,6,5} is "DIIDID".
Your task is to reverse this computation: You are given a String signature containing the signature of a permutation.
Find and return the lexicographically smallest permutation with the given signature.
If no such permutation exists, return an empty int[] instead.
|