Microsoft interview question

Compress a string with no external storage such as a HashMap.