Array permutations

Question

Given an array, arr, of unique integers, write a function to find all possible permutations.

For example:

Input : arr = [4,5,6]
Output : [[4, 5, 6],
[4, 6, 5],
[5, 4, 6],
[5, 6, 4],
[6, 4, 5],
[6, 5, 4]]
                
Input : arr = [10,14,15]
Output : [[10, 14, 15],
 [10, 15, 14],
 [14, 10, 15],
 [14, 15, 10],
 [15, 10, 14],
 [15, 14, 10]]

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now