title: How do I design a system to find top K trending posts in a time window
body: <p>I am working on a system design problem and I need to surface the top K trending posts in 5 min, 1 hour and 24 hour windows.</p>
  <p>I understand the approach of finding Top K element by using a hash map to keep track of frequency and a heap to sort K items by frequency.</p>
  <p>But, I am not sure how to account for time components. I keep reading about buckets/counters etc but I am unable to come up with a solution.</p>
  <p>I am looking to understand the algorithm first before working out how this would be built in a distributed fashion.</p>
  <p>Thank you very much!</p>