Close
Topic list
Permutations of a String
MEDIUM
15 mins
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Permutations of a String

Contributed by
Ankit Kharb
Medium
0/80
Avg time to solve 15 mins
Success Rate 85 %
Share

## Problem Statement

#### For example :

``````If the string is “bca”, then its permutations in lexicographically increasing order are { “abc”, “acb”, “bac”, “bca”, “cab”, “cba” }.
``````
##### Note:
``````Given string contains unique characters.
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````3
abc
bc
c
``````
##### Sample Output 1:
``````abc acb bac bca cab cba
bc cb
c
``````
##### Explanation for Sample Input 1:
``````In the 1st test case, there are 6 permutations of the given string.
In the 2nd test case, there are 2 permutations of the given string.
In the 3rd test case, there is only 1 permutation of the given string.
``````
##### Sample Input 2:
``````1
xyz
``````
##### Sample Output 2:
``````xyz xzy yxz yzx zxy zyx
``````
Auto
Console