Simple JAVA solution (beats 99%)
Intuition\nCount Negative Elements: Count the total number of negative elements in the matrix.\n\n- Even Negatives: If the count of negative elements is even, a
# Intuition\nCount Negative Elements: Count the total number of negative elements in the matrix.\n\n- **Even Negatives**: If the count of negative elements is even, all negative elements can be converted to positive since there are no constraints on the number of multiplications.\n\n- **Odd Negatives**: If the count of negative elements is odd, one element will remain negative. In this case:\n\n1. Find the minimum absolute value in the matrix.\n2. Subtract this value twice from the total sum of the matrix to remove the negative contribution from the sum.\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\nO(m*n)\n\n- Space complexity:\nO(1)\n\n# Code\n```java []\nclass Solution {\n    public long maxMatrixSum(int[][] matrix) {\n        int r = matrix.length;\n        int c = matrix[0].length;\n        int negativeCount = 0;\n        int mini = Integer.MAX_VALUE;\n        long sum = 0;\n\n        for(int i=0; i<r; i++){\n            for(int j=0; j<c; j++){\n                int num = matrix[i][j];\n                if(matrix[i][j] < 0){\n                    negativeCount++;\n                    num = -num;\n                }\n                mini = Math.min(mini, num);\n                sum += num;\n            }\n        }\n\n        if(negativeCount%2 == 0){ //even negative count\n            return sum;\n        }else{ //odd negative count\n            return sum - 2 * mini;\n        }\n    }\n}\n```
['Java']