title: Realtime tracking of top 100 twitter words per min/hour/day
body: <p>I recently came across this interview question:</p>
  
  <pre><code>Given a continuous twitter feed, design an algorithm to return the 100 most
  frequent words used at this minute, this hour and this day.
  </code></pre>
  
  <p>I was thinking of a system with a hash map of <code>word -&gt; count</code> linked to 3 min-heaps for the current min, hour and day.</p>
  
  <p>Every incoming message is tokenized, sanitized and the word counts updated in the hash map (and  increase-key in the heaps if the word already exists in it)</p>
  
  <p>If any of the words don't exist in the heap (and heap size == 100) check if their <code>frequency &gt; min value</code> in the heap and if so then extract-min and insert into the heap.</p>
  
  <p>Are there better ways of doing this?</p>