leetcode

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

2610.cpp (381B)


      1 class Solution {
      2   public:
      3     vector<vector<int>> findMatrix(const vector<int> &nums) {
      4         int count[201] = {0};
      5         vector<vector<int>> res;
      6         for (int n : nums) {
      7             if (count[n] >= res.size())
      8                 res.push_back({n});
      9             else
     10                 res[count[n]].push_back(n);
     11             count[n]++;
     12         }
     13         return res;
     14     }
     15 };