← All problems
Permutations
MediumBacktracking
Given an array of distinct integers, return all possible permutations.
Examples
Input: [1,2,3]
Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
Hints
Solution
Language:
Loading editor…
Output0 lines
Run your code to see output here.
Click Run all tests to check your solution against 3 test cases.