Permutation - 2 (Contest)
Permutation - 2 easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Permutation - 2 easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Problem Statement :
A β permutation is simply a name for a reordering. So the permutations of the string βabcβ are βabcβ, βacbβ, βbacβ, βbcaβ, βcabβ, and βcbaβ. Note that a sequence is a permutation of itself (the trivial permutation). For this problem, youβll need to write a β recursiveβ function ββ that takes a string and returns a list of all its permutations. A couple of notes on the requirements:
The order of the returned permutations must be lexicographically.
Avoid returning duplicates in your final list. Input Input contains a single string S.
Constraints:- 1<=|S|<=8 Output Print all the permutations of string S in lexicographical order. Example Sample Input: ABC
Sample Output : ABC ACB BAC BCA CAB CBA
Explanation: all permutation are arranged in lexicographical order .
Sample Input: (T(
Sample Output:- ((T (T( T((
link: