Problem: Contest Page | CodeChef
DIFFICULTY:
EASY.
PROBLEM:
Chef has an array of N natural numbers most of them are repeated. Cheffina challenges chef to find all numbers(in ascending order) whose frequency is strictly more than K.
Program:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t,x,n,k;
cin>>t;
while(t--){
cin>>n>>k;
map<int,int>mp;
for(int i=0;i<n;i++){
cin>>x;
mp[x]++;
}
for(auto m:mp){
if(m.second>k)cout<<m.first<<" ";
}
cout<<"\n";
}
}