...

/

Print All Permutations of a String

Print All Permutations of a String

Print all permutations of a given string.

Statement

Given a string, print all possible permutations of the string.

Example

All permutations of string “bad” are:

foo a bad bda abd adb dab dba

Sample input

"bad"

Expected output

["bad", "bda", "abd", "adb", "dab", "dba"] 

Try it yourself

Note: The order in which the permutations are generated or returned does not affect the correctness of the solution.

#include <iostream>
#include <vector>
#include <string>
using namespace std;
vector<string> PermuteString(string input) {
vector<string> output;
//TODO: Write - Your - Code
return output;
}

Solution

Let’s discuss a few basics first. We know that n!n! ...