C3 AI interview question

Technical Phone Screen asked this question initially: https://leetcode.com/problems/top-k-frequent-elements/ After he asked how this could be done when the data comes as an infinite stream instead of a list.