Skip to content

Instantly share code, notes, and snippets.

@mooncrater31
Created October 13, 2019 09:29
#define f(i,s,n) for(int i=s;i<n;i++)
vector<int> Solution::findPerm(const string A, int B) {
int u = 0 , d = 0 ;
f(i,0,B-1)
{
if(A[i]=='I') u++ ;
else d++ ;
}
vector<int> v ;
int uptr = d+2 ;
int dptr = d ;
v.push_back(d+1) ;
f(i,0,B-1)
{
if(A[i]=='I') v.push_back(uptr++) ;
else v.push_back(dptr--) ;
}
return v ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment