Can you tell whats wrong with my code?

hello @akash_281
in line 32 it should be i<=max_value

I did that but then I am getting TLE in some cases.

then dont iterate from 0…max_value.

instead iterate ur frequency map. if frequency > n/3 print the key

#include
using namespace std;
#include
#include<unordered_map>
#include<bits/stdc++.h>
#include
int main()
{
int n;
cin>>n;
vector v;
unordered_map<int,int> m;
for(int i=0;i<n;i++)
{
int num;
cin>>num;
// v.push_back(num);
m[num]++;
}
// for(int i=0;i<100;i++)
// {
// cout<<m[i];
// }
int min_req=floor(n/3);
// cout<<min_req;
// for(int i=0;i<1000;i++)
// {
// if(m[i]>min_req)
// {
// cout<<i<<" “;
// }
// }
for(auto p:v)
** {**
** if(p.second>min_req)**
** {**
** cout<<p.first<<” ";**
** }**
** }**

return 0;

}

getting an error now

source.cpp: In function ‘int main()’:
source.cpp:35:14: error: request for member ‘second’ in ‘p’, which is of non-class type ‘int’
35 | if(p.second>min_req)
| ^~~~~~
source.cpp:37:21: error: request for member ‘first’ in ‘p’, which is of non-class type ‘int’
37 | cout<<p.first<<" ";

pls save ur code in cb ide and then share its link.

check now->

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.