TIME O(n), SPACE O(1) || C++ || EASY TO UNDERSTAND
here we return diagonal sum of an array.\nsize of matrix = n*n.\ndiagonal elements are (i==j)&&(i==n-1-j).\nso we return sum of v[i][j]+v[i][n-1-i];\nif n odd t
here we return diagonal sum of an array.\nsize of matrix = n*n.\ndiagonal elements are (i==j)&&(i==n-1-j).\nso we return sum of v[i][j]+v[i][n-1-i];\nif n odd than we add v[n/2][n/2] add two times in ans array so we subtract it one time from ans_sum;\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int diagonalSum(vector<vector<int>>& mat) {\n        int n = mat.size(),i,sum=0;\n        for(i = 0; i < n; i++){\n            sum += mat[i][i];\n            sum += mat[i][n-1-i];\n        }\n        if(n&1)sum -= mat[n/2][n/2];\n        return sum;\n    }\n};\n```
['C++']