leetcode

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

1356.cpp (316B)


0 class Solution { 1 public: 2 vector<int> sortByBits(vector<int> &arr) const { 3 sort(begin(arr), end(arr), [](int a, int b) { 4 const int x = __builtin_popcount(a); 5 const int y = __builtin_popcount(b); 6 return x != y ? x < y : a < b; 7 }); 8 return arr; 9 } 10 };