low to 0 and high to the length of the string s.perm of size n + 1 to hold the permutation.s using an index i:
s[i] is 'I', set perm[i] to low and increment low.s[i] is 'D', set perm[i] to high and decrement high.perm[n] to the remaining value of low (which is equal to high at this point).perm.