Java || Beats 99.19%
Complexity\n- Time complexity: O(n*m)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# 
# Complexity\n- Time complexity: O(n*m)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public long maxMatrixSum(int[][] matrix) {\n        int min = Integer.MAX_VALUE; // Smallest absolute value\n        long sum = 0; // Total sum of absolute values\n        int neg = 0; // Count of negative numbers\n\n        // Traverse the matrix\n        for (int[] row : matrix) {\n            for (int val : row) {\n                if (val < 0) {\n                    neg++; // Increment negative count\n                    val = Math.abs(val); // Convert to positive\n                }\n                if (val < min) {\n                    min = val; // Update minimum absolute value\n                }\n                sum += val; // Add to the sum\n            }\n        }\n\n        // If the count of negatives is odd, adjust the sum\n        if (neg % 2 == 1) {\n            sum -= (min * 2);\n        }\n\n        return sum; // Return the result\n    }\n}\n\n```
['Java']