Challenge: All Permutations of an Integer List
Let’s generate all permutations of an integer array using recusion.
We'll cover the following
Problem
Given an integer array, generate all permutations of the integer array.
Input
An integer array.
Output
All permutations of the integer array.
Sample input
array = [0,1,2]
Sample output
// All possible permutations
[0 1 2]
[0 2 1]
[1 0 2]
[1 2 0]
[2 1 0]
[2 0 1]
Coding exercise
Try to solve this yourself first. If you get stuck or need help, you can always press the “Show Solution” button to see how your problem can be solved. We’ll look at the solution in the next lesson.
Good luck!
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.