Easy solution using deque


#1

vector Solution::findPerm(const string str, int n) {
deque mylist;
for(int i=1;i<=n;i++)
{
mylist.push_back(i);
}

vector<int> vec;
for(int i=0;i<str.length();i++)
{
    if(str[i]=='I')
    {
    vec.push_back(mylist.front());
    mylist.pop_front();
    }
    if(str[i]=='D')
    {
        vec.push_back(mylist.back());
        mylist.pop_back();
    }
    
}

vec.push_back(mylist.front());
mylist.pop_front();

return vec;

}