Example 1 : Permutations

TopicDifficultyCompanies
Backtracking
MEDIUM
Microsoft
Adobe
Google

Given a collection of distinct integers, write a program to return all possible permutations.

Example

Input: [1,2,3]
Output:
[
[1,2,3],
[1,3,2],
[2,1,3],
[2,3,1],
[3,1,2],
[3,2,1]
]

Code Editor

Practice and Learn

Best way to learn is through solving real problems. Practice this problem in this code editor.