Skip to content

Instantly share code, notes, and snippets.

@bkb181
Last active June 2, 2020 06:00
Show Gist options
  • Save bkb181/621f5a3a136d0f0475ac2f0b3beebfcf to your computer and use it in GitHub Desktop.
Save bkb181/621f5a3a136d0f0475ac2f0b3beebfcf to your computer and use it in GitHub Desktop.
void permutation(string str, int i)
{
int n=str.size()
if (i == n - 1)
{
cout << str << endl;
return;
}
for (int j = i; j < n; j++)
{
swap(str[i], str[j]);
permutation(str, i + 1);
swap(str[i], str[j]); //swap is built-in function in CPP
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment