C++ Easy Solution|| linear time O(n) & O(1) space


#1
vector<int> Solution::findPerm(const string A, int B) {
    vector<int> v;
    int l=1,r=B;
    int i=0;
    if(!A.length())return v;
    while(l<=r && v.size()!=A.length()+1)
    {
        if(A[i]=='I')
        {
           v.push_back(l);
           l++;
        }
        else
        {
            v.push_back(r);
            r--;
        }
        i++;
    }
    return v;
    
    
}