```
public int[] FindPermutation(string s) {
int n = s.Length, i = 0, v = 1;
int[] r = new int [n + 1];
for(i = 0; i <= n; i++) r[i] = i + 1;
i = 0;
while(i < n) {
while(i < n && s[i] == 'I') i++;
int sd = i;
while(i < n && s[i] == 'D') i++;
int j = sd, k = i;
while(j < k) {
int t = r[j];
r[j++] = r[k];
r[k--] = t;
}
}
return r;
}
```