[C++] No dynamic programming
I was just about to implement a dynamic programing but then I figured out that the elements can be changed in chains. So then I start wondering what will be the
I was just about to implement a dynamic programing but then I figured out that the elements can be changed in chains. So then I start wondering what will be the result:\nThe sum of all numbers as they are positive (sum of absolute values) - x. Three cases to determine x:\n1. x == 0  if negative values are even (all the numbers can be transformed in positives)\n2. x == 0 if at least 1 zero is present\n3. if not the case of 1) or 2) then x == 2 * min_aboslute value of the matrix\n# Code\n```cpp []\nclass Solution {\npublic:\n    long long maxMatrixSum(vector<vector<int>>& matrix) {\n        long long sum = 0;\n        int negative = 0, min_abs = INT_MAX, zero = 0, n = matrix.size();\n        for (int i = 0; i < n; i++) {\n            for (int j = 0; j < n; j++) {\n                sum += abs(matrix[i][j]);\n                zero += (matrix[i][j] == 0);\n                negative += (matrix[i][j] < 0);\n                min_abs = min(min_abs, abs(matrix[i][j]));\n            }\n        }\n        long long subtract = 2LL * min_abs;\n        if (zero > 0 || (negative & 1) == 0) \n            subtract = 0;\n        return sum - subtract;\n    }\n};\n```
['C++']