you give stre s reorder string follow algorithmpick small character s append resultpick small character s great appended character result append itrepeat step 2 pick characterspick large character s append resultpick large character s small appended character result append itrepeat step 5 pick charactersrepeat step 1 6 pick character sin step if small large character appear choose occurrence append resultreturn result string sort s algorithm Example 1input s aaaabbbbccccoutput abccbaabccbaexplanation after step 1 2 3 iteration result abcafter step 4 5 6 iteration result abccbafirst iteration now s aabbcc step 1after step 1 2 3 second iteration result abccbaabcafter step 4 5 6 second iteration result abccbaabccbaexample 2input s ratoutput artexplanation the word rat art reorder mention algorithm Constraints1 slength 500s consist lowercase english letter