private void reverse(int[] result, int start, int end) {

        while(start < end) {
            int tmp = result[start];
            result[start] = result[end];
            result[end] = tmp;
            start++;
            end--;
        }
    }
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