simple approach
\n\n# Complexity\n- Time complexity:\nO(n2)\n\n# Code\n\nclass Solution {\npublic:\n    long long maxMatrixSum(vector<vector<int>>& matrix) {\n        int neg=0
\n\n# Complexity\n- Time complexity:\nO(n2)\n\n# Code\n```\nclass Solution {\npublic:\n    long long maxMatrixSum(vector<vector<int>>& matrix) {\n        int neg=0;\n        long long sum=0;\n        int mini=INT_MAX;\n        for (int i=0; i<matrix.size(); i++)\n        {\n            for (int j=0; j<matrix[0].size(); j++)\n            {\n                if (matrix[i][j]<0)\n                {\n                    neg+=1;\n                }\n                sum+= abs(matrix[i][j]);\n                if (abs(matrix[i][j]) <mini)\n                {\n                    mini= abs(matrix[i][j]);\n                }\n            }\n        }\n        return(neg%2)?sum-(2*mini):sum;\n    }\n};\n```
['C++']