Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer. NOTE: One or two additional variables are fine. An extra copy of the array is not. FOLLOW UP Write the test cases for this method.
Tips:
Confirm how to order the string after removed the duplicates. Exp. "accffcfa" could be either "acf" or "cfa" after removing duplicates
Confirm if an array with fixed size is allow to use, or no array is allowed at all.
If a fixed sized array is allowed, we can use it to count the occurrence of the characters.
Use [NSString stringByReplacingOccurrencesOfString] to replace the duplicated characters with “”, it has the same effect with delete function.