what is wrong in this code(in today contest)???

class Solution {
public:
vector mostVisited(int n, vector& rounds) {
int i,count=0,count1=0,x=0;
vector a;
// if(n>0){
sort(rounds.begin(),rounds.end());
for(i=0;i<rounds.size()-1;i++)
{
if(rounds[i]==rounds[i+1])
{
count++;
}
else
{
count1=count;
if(count>count1)
{
x=rounds[i];
a.push_back(rounds[i]);
}
count=0;
}
}
// cout<<x;
return a;
// else
// {
// return null;
// }
}
};
// class Solution
// {
// public:
// vector mostVisited(int n, vector& rounds)
// {
// int count=0,i=0,x=0;
// vector b;
// unordered_map<int,int> a;
// a[rounds[i++]];
// for(auto i:a)
// {
// if(count<i.second)
// {
// b.push_back(i.first);
// x=i.first;
// count=i.second;
// }
// }
// return b;
// }
// };

Comments (0)