leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1636.cpp (452B)


0 class Solution { 1 public: 2 vector<int> frequencySort(vector<int> &nums) const { 3 static int count[201]; 4 5 memset(count, 0x00, sizeof(count)); 6 for (const int n : nums) 7 count[n + 100]++; 8 9 sort(begin(nums), end(nums), [&](int a, int b) { 10 const int x = count[a + 100]; 11 const int y = count[b + 100]; 12 13 return x != y ? x < y : a > b; 14 }); 15 16 return nums; 17 } 18 };