**I have used a greedy algorithm:**

- Loop on the input and insert a decreasing numbers when see a 'I'
- Insert a decreasing numbers to complete the result.

**Simple example:**

Input: "DIDDID"

0 []

1 [2, 1]

2 [2, 1]

3 [2, 1]

4 [2, 1, 5, 4, 3]

5 [2, 1, 5, 4, 3]

[2, 1, 5, 4, 3, 7, 6]

Then, output is [2, 1, 5, 4, 3, 7, 6]

```
def findPermutation(self, s):
ret = []
for i in range(len(s)):
if s[i] == 'I':
ret.extend(range(i + 1, len(ret), -1))
ret.extend(range(len(s) + 1, len(ret), -1))
return ret
```

Hope that you like my solution. :)