LeetCode - Matrix Block Sum

Author: Jesse Choe


Time Complexity: O(NM)\mathcal O(NM)

Implementation

C++

class Solution {
public:
vector<vector<int>> matrixBlockSum(vector<vector<int>> &mat, int K) {
int n = mat.size(), m = mat[0].size();
vector<vector<int>> arr(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) { arr[i].push_back(mat[i][j]); }
}
vector<vector<int>> dp(n + 1);
for (int i = 0; i <= n; i++) {

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!