All Permutations
InterviewTime limit1sMemory limit256 MB
Print every permutation of the numbers 1 to N in lexicographic order, one per line.
- Level
Easy3 of 10
- Topics
- Backtracking, Recursion
- Solved
- No attempts yet
Problem
Given , print every permutation of the numbers through in lexicographic order.
Input
The first line contains . ()
Output
Starting from the first line, print all permutations in lexicographic order over lines. Print one permutation per line, with a single space between numbers.