Skip to content
C

Generate All Permutations

Mediumjavapythonccppjavascript

Given an array of distinct integers, generate every ordering of its elements, in lexicographic order.

Input Format

The first line contains an integer N. The second line contains N space-separated distinct integers.

Output Format

Print N! lines, one per permutation, in lexicographic order (based on the values), space-separated.

Input (stdin)

Output

Run your code to see output here...