Maslo Consulting interview question

Compress the string with out breaking the sequence.