Permutations of the String

hardRecursionBacktrackingsorting

You are given a string $$$s$$$ consisting of pairwise distinct lowercase English letters.

Your task is to generate all possible permutations of the characters in the string and output them in lexicographical order.

Input Format:

The only line contains a string $$$s$$$ $$$(1 \le |s| \le 8)$$$ consisting of lowercase English letters. All characters in $$$s$$$ are pairwise distinct.

Output Format:

Print all permutations of the string $$$s$$$ in lexicographical order, each on a new line.

Examples:

Example 1:

Input:

abc

Output:

abc
acb
bac
bca
cab
cba

Code

Loading Editor...