Few lines easy solution in C++


#1
vector<int> Solution::findPerm(const string A, int B) 
{
    int n=A.length();
    vector<int>v(n+1);
    int start=1,end=n+1;
    for(int i=0;i<=n;i++)
    {
        v[i]=(A[i]=='I'?start++:end--);
    }
    return v;
}