Top k most frequent number in the running integer stream

Can you please explain me this question with example? I don’t understand

hello @div_yanshu07
in this question after every element taking as input we have to print the to k most frequent characters.
lets take the example of :
5 1 3 5 2
first there is 5(input) there will be output 5
then we take 1 as input and output will be 1 5
then 3 as the input and the output will be 1 3 .
then 5 came in input and the freq of 5 becomes 2 and the output will be 5 1
then 2 came as input and output will be 5 1
output : 5 1 5 1 3 5 1 5 1