Pergunta de entrevista da empresa Bloomberg

Remove consecutive duplicates in a string inplace and less than O(n)