Matrix Diagonal Sum || time-> O(m) || c++
```\nclass Solution {\npublic:\n    int diagonalSum(vector>& m) {\n        \n        int total=m.size();                 // total size of square matrix\n       
```\nclass Solution {\npublic:\n    int diagonalSum(vector<vector<int>>& m) {\n        \n        int total=m.size();                 // total size of square matrix\n        int s=0,r=0,e=total-1;              // s-> starting,  r-> row,  e-> ending\n        int sum=0;\n        \n        // if the square matrix length is odd\n        if((total&1) == 1)              // checking for odd condition using bitwise and (&)\n            while(r<total)\n            {\n                sum = sum + m[r][s] + m[r][e];\n                if(e==s)\n                    sum=sum-m[r][s];            // since the middle diagonal is add for 2 times, so we subtract for 1 time\n                s++;e--;                        // now increasing all values \n                r++;\n            }\n        \n        // if the square matrix length is even\n        else\n            while(r<total)\n            {\n                sum = sum + m[r][s++] + m[r][e--];\n                r++;\n            }\n        return sum;\n    }\n};
['Array', 'C', 'Matrix']