Input: BDCAbaxz
OUTPUT: AaBbCDxz
My solution is straight forward and ugly:
Sort the input with quick sort, then we get "ABCDabxz"
Alloc a temp array with the same size as the original one, then take the appropriate element from two sub-array(ptr1-->A, ptr2--->a)
Copy the temp array back to the original one
Any faster algorithm on this problem?