Explain the test case
Explain the test case
@sharad1103
5 2
5 1 3 5 2
What running stream means here is :- we will start from i=0 to n-1 and lets suppose at instant i=3, it means we need to consider elements from index 0 till 3 for our answer.
for example :- i=2, it means we need to consider elements 5,1,3 for answer.
So then as said in this question, we need to print top k frequent items, it means the elements with high freq, if freq is equal then smaller number is preferred.
In this example:-
i=0 => 5
i=1 => 1, 5 (because freq of both are same in running stream).
i=2 => 1, 3 (because 1 and 3 are smaller than 5 and we need to consider k=2 elements only).
i=3 => 5,1 (because 5 has freq=2 while others have freq=1).
i=4 => 5, 1 (again same as freq of 5=1 and others is one so we select the minimum).
I hope this explanation will enable you to understand the question.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.