C++ || Easy || 2 line code
Intuition\n\nWhy think to travel whole matrix , let\'s travel elements that\'s we need to add in our final answer.\n\n# Approach\n\nThere is Two diogonal Primar
# Intuition\n***\nWhy think to travel whole matrix , let\'s travel elements that\'s we need to add in our final answer.\n\n# Approach\n***\nThere is Two diogonal Primary and Secondry:-\n\n  Primary Diogonal contain all the elements where i = j , or row number = colomn number  can be represent in form of `matrix[i][i]` .\n\nSecondry Diogonal will be start from first row and last element and continuesly dicreasing one on both row number and colomn number, can be represented in form of `matrix[i][n-i-1]` where n is size of matrix and i will move from 0 to N.\n\n\nONE THING TO NOTED :- In this way we will be adding center element( 1 Common element ) 2 times when n id=s ODD. To deal with `i != n-i-1` should not be equal , \nWe are checking only colomn number , because we will having always same row number in traversal.\n\n***\n```\nHOPE YOU LIKE IT !! PLEASE VOTE UP...\n```\n*** \n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(1)\n\n# Code\n***\n```\nclass Solution {\npublic:\n    int diagonalSum(vector<vector<int>>& mat) {\n        int n = mat.size() , ans =0;\n        for(int i=0;i<n;i++){\n            ans+=mat[i][i];\n            if( i != n-i-1) ans+=mat[i][n-i-1];\n        }\n        return ans;\n    }\n};\n```\n***\n```\nHOPE YOU LIKE IT !! PLEASE VOTE UP...\n```\n***
['C++']