Simple Brute Force method using index values in C++ / O(n) Solution.
IntuitionAs the constraints are too small we can go through the brute force approach.ApproachDiagonal elements can occur only at index where (i==j) i.e row inde
# Intuition
As the constraints are too small we can go through the brute force approach. 

# Approach
Diagonal elements can occur only at index where (i==j) i.e row index = column index or diagonal element can occur at such index where sum of row index and column index is equal to n-1. Here n is the size of matrix. 

# Complexity
- Time complexity:
As the loop iterates single time over the matrix , it gives solution in linear time complexity. Due to small constraints the complexity is O(n). 

- Space complexity:
No extra space is taken so the space complexity is O(1).

# Code
```cpp []
class Solution {
public:
    int diagonalSum(vector<vector<int>>& mat) {
        int n = mat.size();
        int m = mat[0].size();
        int sum = 0;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
               if(i==j || i+j == (n-1)){
                sum += mat[i][j];
               }
            }
        }
        return sum;
    }
};
```
['C++']