title: Compressing a string
body: <p>There is a frequently asked question in interviews about compressing a string.
  I'm not looking for a code, I only need an efficient algorithm that solves the problem.</p>
  
  <p><strong>Given a string (<em>e.g. aaabbccaaadd</em>), compress it (<em>3a2b2c3a2d</em>).</strong></p>
  
  <p>My solution:</p>
  
  <blockquote>
    <p>Travel on the string. Every time I see the same letter I count it.
    I will output the letter and the counter when I see a different letter coming (and start over again).</p>
  </blockquote>
  
  <p>Is there more efficient way to do this?</p>
  
  <p>Thanks</p>