maneedhar
12/20/2018 - 2:44 AM

Code Signal 08

int matrixElementsSum(std::vector<std::vector<int>> m) {
    int n = m.size();
    int k = m[0].size();
    int s = 0;
    for (int i=0; i<n-1; i++){
        for (int j=0; j<k; j++){
            if (m[i][j] == 0){
                m[i+1][j] = 0;
            }
        }
    }
    for (int i=0; i<n; i++){
        for (int j=0; j<k; j++){
            s += m[i][j];
        }
    }
    return s;
}