Tricky Permutation

I am using pair instead of vectors and some of the test cases are getting wrong, So please tell me is this approach right or not and also what i am doing wrong in this.

@Adarsh25trivedi In the question it is given that you have to avoid duplicates.
Consider a case:
ABCA

Your O/P:
AABC
AACB
ABAC
ABCA
ACAB
ACBA
BAAC
BACA
BCAA
CAAB
CAAB
CABA
CABA
CBAA

Expected O/P:
AABC
AACB
ABAC
ABCA
ACAB
ACBA
BAAC
BACA
BCAA
CAAB
CABA
CBAA

1 Like