Beginner's C++ solution easy


#1
vector<int> Solution::findPerm(const string A, int B) {
    int n=A.length();
    vector<int> d(n);
    vector<int> num(B);
    int cd=0;
    for(int i=0;i<n;i++)
    {
        if(A[i]=='D')
        {
            d[i]=1;
            cd++;
        }
    }
    int start=1;
    int end=B;
    
    for(int i=0;i<B;i++)
    {
        if(d[i]==0)
        {
            num[i]=start;
            start++;
        }
        else
        {
            num[i]=end;
            end--;
        }
    }
    
    return num;
}