Amazon interview question

Write an algorithm to compress a string?