A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where:


	s[i] == 'I' if perm[i] &lt; perm[i + 1], and
	s[i] == 'D' if perm[i] &gt; perm[i + 1].


Given a string s, reconstruct the permutation perm and return it. If there are multiple valid permutations perm, return any of them.

&nbsp;
Example 1:
Input: s = "IDID"
Output: [0,4,1,3,2]
Example 2:
Input: s = "III"
Output: [0,1,2,3]
Example 3:
Input: s = "DDI"
Output: [3,2,0,1]

&nbsp;
Constraints:


	1 &lt;= s.length &lt;= 105
	s[i] is either 'I' or 'D'.


class Solution:
    def diStringMatch(self, s: str) -> List[int]:
        result = []
        min_ = 0
        max_ = len(s)
        for x in s:
            if x=="I":
                result.append(min_)
                min_ += 1
            elif x=="D":
                result.append(max_)
                max_ -= 1
        result.append(min_)
        return result
class Solution {
    public int[] diStringMatch(String s) {
        int low = 0;
        int high = s.length();
        int[] ans = new int[s.length() + 1];
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == 'I'){
                ans[i] = low++;
            } else{
                ans[i] = high--;
            }
        }
        ans[s.length()] = high;
        return ans;
    }
}
class Solution {
public:
    vector<int> diStringMatch(string s) {
        int p=0, j=s.size();
        vector<int>v;
        for(int i=0; i<=s.size(); i++)
        {
            if(s[i]=='I')v.push_back(p++);
            else v.push_back(j--);
        }
        return v;
    }
};
var diStringMatch = function(s) {
    let i = 0, d = s.length, arr = [];
    
    for(let j = 0; j <= s.length; j += 1) {
        if(s[j] === 'I') arr.push(i++);
        else arr.push(d--);
    }
    
    return arr;
};
DI String Match