vector<string> generate_permutations(string word)
{
vector<string> result;
...
for (int i = 0; i < word.length(); i++)
{
string shorter_word = word.substr(0, i)
+ word.substr(i + 1, word.length() - i - 1);
...
}
return result;
}
vector<string> shorter_permutations = generate_permutations(shorter_word);
for(int j = 0; j < shorter_permutations.size(); j++)
{
string longer_word = word[i] + shorter_permutations[j];
result.push_back(longer_word);
}
if (word.length() == 1)
{
result.push_back(word);
return result;
}