public static void main(String args[]){
        String input = "IIIDIIDDDDIIDDD";
        GenerateSignature gs = new GenerateSignature();
        int result[] = gs.generate(input.toCharArray());
        for(int i=0; i < result.length; i++){
            System.out.print(result[i] + " ");
        }
    }
You are given an array of n elements [1,2,....n]. For example {3,2,1,6,7,4,5}. Now we create a signature of this
array by comparing every consecutive pir of elements. If they increase, write I else write D.
For example for the above array, the signature would be "DDIIDI". The signature thus has a length of N-1.
Now the question is given a signature, compute the lexicographically smallest permutation of [1,2,....n].

Time complexity O(n)
Space complexity O(1)

Reference https://learn.hackerearth.com/forum/182/lexicographically-smallest-permutation-given-a-signature/
src/com/interview/number/GenerateSignature.java