C++ O(n) Simple Solution
\nclass Solution {\npublic:\n    int diagonalSum(vector<vector<int>>& mat) {\n     int n = mat.size() ;\n     int ans = 0 ;\n        \n     for(int i = 0 ; i < 
```\nclass Solution {\npublic:\n    int diagonalSum(vector<vector<int>>& mat) {\n     int n = mat.size() ;\n     int ans = 0 ;\n        \n     for(int i = 0 ; i < n ; i++){\n        ans = ans + mat[i][i] + mat[i][n - i - 1] ;  \n      }\n      ans = (n & 1) ? ans - mat[n/2][n/2] : ans ;//if n is odd then we have to subtract mat[n/2][n/2] from the ans because we add it twice earlier.\n      return ans ;  \n    }\n};\n```
['C', 'C++']