Can anyone please explain where my solution is failing. I can’t figure it out myself.
what error are you getting ?
Dont know… I am checking my solution with some testcases and also the AC solutions.Both are giving same result.Still WA.
You are getting wrong answers for these test cases
correct ans = AAAAB
correct ans = ABCDE
correct ans = AAB
correct ans = ABCDD
Thanks a lot.I was not considering this testcases. @shivam217
For the case :
correct ans should be ABDCD
bro, if we pick “D” and move it last position then we will get “ABCDD” and “ABCDD” is lexicographically smaller than “ABDCD” .
oh yes…sorry my bad
for the test case DABC your code will give ans ADBC but the correct ans would be
ABCD (by moving D to the end)