How To Minimize a String(WA)

Go through the Link Of the question b4 reading the follwing lines
Link of the Question:-DIVGOLD Problem - CodeChef

In The question it has been asked that we are allowed to perform only one ty[e of operation i.e:
Choose any position in the string, remove the character at that position and insert it back to any other place in the string.
eg:DCBA
ADCB
The above solution is possible if only one opeartion is possible
My solution:CodeChef: Practical coding for everyone
Following strictly that only one opearation si possible I am getting WA.
Plz help

Your logic is not completely right.

Consider the

Input

ABACDA

for this input output must be

OUTPUT

AABACD

But your code’s output is “AABCD

what your code is doing, if same character (character that to be replaced) exist in the input more than once then it will not displaying that character again. Do correct it.

Hope it helps.