5

Print Permutations - String

Difficulty: EASY
Avg. time to solve
30 min
Success Rate
80%

Problem Statement
Suggest Edit

Given an input string S, find and return all possible permutations of the input string.

Note:
The input string may contain the same characters, so there will also be the same permutations.
The order of permutations doesn’t matter.
Input Format:
The only input line contains a string S of alphabets in lower case characters.
Output Format:
Print each permutation in a new line 
Note:
You do not need to print anything, it has already been taken care of. Just implement the function.  
Constraint:
0<=|S|<=8
where |S| denotes the length of string S.
Time Limit: 1 sec
Sample Input 1:
cba
Sample Output 1:
abc
acb
bac
bca
cab
cba
Sample Input 2:
xyx
Sample Output 2:
xyx
xxy
yxx
yxx
xyx
xxy
Want to solve this problem? Login now to get access to solve the problems