Find Permutation Time : Space : 1234567891011vector<int> Solution::findPerm(const string A, int B) { vector<int> res{1}; int l = 1, r = 1; for(int i = 0; i < A.length(); i++) { if(A[i] == 'I') res.push_back(++r); else res.push_back(--l); } for(int i = 0; i < res.size(); i++) res[i] += (1 - l); return res;}