Created
June 2, 2020 06:03
-
-
Save bkb181/e2224814d7faf51ed4bbc567905da2e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void permutation(string S, int n, string res) | |
{ | |
if (n == 1) | |
{ | |
cout << res + S << endl; | |
return; | |
} | |
for (int i = 0; i < n; i++) | |
{ | |
permutation(S.substr(1), n - 1, res + S[0]); | |
rotate(S.begin(), S.begin() + 1, S.end()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment