My code is correct but still giving WA

My code is correct but it is giving WA because my solution print 4 3 instead of 3 4. Both of which are correct. What should I do?

correct ans is 3 4 only
because 3’s freq is more than 4

send me the code i will check your code

i saw your code

your approach is not correct

else{
                auto top=pq.top();
                if(top.first<it->second){
                    pq.pop();
                    pq.push({it->second,it->first});
                }
            }

here is an element is not greater that pq.top() but it may also be the part of k most frequent element
but you didn’t consider this case;

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.