leetcode

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

2679.cpp (439B)


      1 class Solution {
      2   public:
      3     int matrixSum(const vector<vector<int>> &nums) const {
      4         static int maxi[501];
      5         memset(maxi, 0x00, sizeof(maxi));
      6 
      7         const int m = nums[0].size();
      8         for (auto row : nums) {
      9             sort(row.begin(), row.end());
     10             for (int i = 0; i < m; i++)
     11                 maxi[i] = max(maxi[i], row[i]);
     12         }
     13 
     14         return accumulate(begin(maxi), begin(maxi) + m, 0);
     15     }
     16 };