Wrong answer for few test cases


Showing wrong ans for test case 6 and 7 plz suggest necessary changes

hey @Vishu_1801
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.
try for this input
ABAA
correct output
AAAB
AABA
ABAA
BAAA
your code gives ;
AAAB
AAAB
AAAB
AABA
AABA
AABA
ABAA
ABAA
ABAA
BAAA
BAAA
BAAA