ansh_u_oo7's blog

By ansh_u_oo7, history, 11 months ago, In English

I solved this question using a vector of pairs can someone give me a better approach for this IT WOULD BE OF REALLY GREAT HELP

vector topK(vector& nums, int k) {

map<int,int>mp;
    for(int i=0;i<nums.size();i++)
    {
        mp[nums[i]]++;
    }
    vector<pair<int,int>>p;
    for(auto it:mp)
    {
        p.push_back(make_pair(it.second,it.first));
    }

    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());
    vector<int>v;
   for(int i=0;i<k;i++)
   {
    v.push_back(p[i].second);    
   }
    return v;
}

Full text and comments »

  • Vote: I like it
  • -16
  • Vote: I do not like it

By ansh_u_oo7, history, 14 months ago, In English

can someone please help me with how to follow a track or how to solve questions in order to be a good competitive programmer

Full text and comments »

  • Vote: I like it
  • -11
  • Vote: I do not like it

By ansh_u_oo7, history, 16 months ago, In English

can somebody please suggest to me how should I learn topics in order to be good at CP? like the order of issues that I should learn in order to achieve at least a Specialist in CF.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it