Print Permutations

easy
1.You are given a collection of distinct integers.
 2.You have to complete the function permute that should return all possible permutations in the following order.
 3.Example For input   -> 1 2 3
 [[2, 3, 1], [3, 2, 1], [3, 1, 2], [1, 3, 2], [2, 1, 3], [1, 2, 3]]

Input Format

First line containing an Integer. Second line contains 'N' space separated integers

Output Format

You have to return list of list all permutation

Constraints

1<=N<=10

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
3
1 2 3
Output
[[2, 3, 1], [3, 2, 1], [3, 1, 2], [1, 3, 2], [2, 1, 3], [1, 2, 3]]
Next
Print Kpc

Related Questions