Write a method to return all permutations of a string.
Anonymous
C++: void permutations(string input, int start, int length) { if (start == length - 1) { cout << input << endl; return; } for (unsigned int i = start; i < length; ++i) { swap(input[start], input[i]); permutations(input, start + 1, length); swap(input[i], input[start]); } }
Check out your Company Bowl for anonymous work chats.