Super Simple C++ solution


#1

vector Solution::findPerm(const string S, int n) {
int i=1; int d=n;
vectorarr(n);
if(S[0] == ‘I’) {
arr[0] = 1;
i++;
}
else if(S[0] == ‘D’){
arr[0] = n;
d–;
}
for(int j=0; j<n-1; j++){
if(S[j+1] == ‘I’) arr[j+1] = i++;
else arr[j+1] = d–;
}
return arr;
}