Skip to content

Latest commit

 

History

History
28 lines (15 loc) · 611 Bytes

Tricky Permutation.md

File metadata and controls

28 lines (15 loc) · 611 Bytes

Tricky Permutations

Given a string containing duplicates, print all its distinct permutations such that there are no duplicate permutations and all permutations are printed in a lexicographic order.

NOTE: DO NOT USE MAP OR SET.

Input Format:

The first and only line of the test case contains the input string.

Constraints:

Length of the string <= 8

Output Format:

Print all the distinct permutations in a lexicographic order such that each permutation is in a new line. Note that there should not be any duplicate permutations.

Sample Input:

ABA

Sample Output:

AAB

ABA

BAA