Google interview question

Write a method to return all permutations of a string.

Interview Answers

Anonymous

10 Nov 2014

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]); } }

5

Anonymous

10 Jul 2020

🚨🚨🚨 Do you want a FULL list of all Google questions asked in the last month? 👉 Go to candor.co/interviews to see 300+ questions and answers based on recent interviews. 💛 Best of all, it's FREE.