Skip to content

Instantly share code, notes, and snippets.

@mooncrater31
Created March 14, 2020 09:38
Show Gist options
  • Save mooncrater31/cd8ef944fd807ef03c71c5cd637afafc to your computer and use it in GitHub Desktop.
Save mooncrater31/cd8ef944fd807ef03c71c5cd637afafc to your computer and use it in GitHub Desktop.
for(int i=n-1;i>=0;i--)
{
int mod = n-i ;
if(P[i]>=mod)
{
P[i]-=mod ;
if(i) P[i-1]++ ;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment