Get a free weekly practice problem!

Keep that axe sharp.

× No thanks

You only have free questions left (including this one).

But it doesn't have to end here! Sign up for the 7-day coding interview crash course and you'll get a free Interview Cake problem every week.

Write a recursive method for generating all permutations of an input string. Return them as a set.

Don't worry about time or space complexity—if we wanted efficiency we'd write an iterative version.

To start, assume every character in the input string is unique.

Your method can have loops—it just needs to also be recursive.

Make sure you have a base case! Otherwise your method may never terminate!

Start your free trial!

Log in or sign up with one click to get immediate access to free mock interview questions

Start your free trial!

Log in or sign up with one click to get immediate access to free mock interview questions

How does the problem change if the string can have duplicate characters?

What if we wanted to bring down the time and/or space costs?

Start your free trial!

Log in or sign up with one click to get immediate access to free mock interview questions

What's next?

Reset editor

Powered by qualified.io

. . .