Diagonal Difference

  • + 0 comments

    c++

    int diagonalDifference(vector<vector<int>> arr) {
        int result = 0;
        for(int i = 0; i < arr.size(); ++i){
            vector<int> const& row = arr[i];
            result += row[i] - row[row.size() - i - 1];
        }
        return std::abs(result);
    }