**Solution**

**Find Permutation** https://leetcode.com/problems/find-permutation/

**Greedy Solution**

- For example, given IDIIDD we start with sorted sequence 1234567

Then for each k continuous D starting at index i we need to reverse [i, i+k] portion of the sorted sequence. - https://discuss.leetcode.com/topic/76221/java-o-n-clean-solution-easy-to-understand
- Thought process: https://goo.gl/photos/LG5TxfAtXAcFfQpC8

```
class Solution(object):
def reverse(self, arr, s, e):
while s < e:
arr[s], arr[e] = arr[e], arr[s]
s, e = s+1, e-1
return
def findPermutation(self, s):
"""
:type s: str
:rtype: List[int]
"""
arr = [i for i in range(1, len(s)+2)]
e = 0
while e < len(s):
if s[e] == "D":
st = e
while e < len(s) and s[e] == "D":
e += 1
self.reverse(arr,st,e)
else:
e += 1
return arr
```