//用lambda void Sortbytimes(vector<int> A) {  int len = A.size();  map<int, int> res;  for (int i = 0;i < len;i++)  {   auto ret = res.insert({ A[i],1 });   if (ret.second == false)    res[A[i]]++;  }  stable_sort(A.begin(), A.end(), [res](const int& a, const int& b) {return  res.at(a)>res.at(b);});;  for (auto a : A)   cout << a << " "; }
点赞 2

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务