java solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nfirst you need to count negative number in the matrix\nsecond minimize th
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nfirst you need to count negative number in the matrix\nsecond minimize the loss\nthied if negative number is even in number the  direct return sum\notherwise return ans-2*min;\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public long maxMatrixSum(int[][] matrix) {\n        long ans = 0;\n        int neg = 0;\n        int min = Integer.MAX_VALUE;\n        for(int i = 0; i < matrix.length; i++){\n            for(int j = 0; j < matrix[0].length; j++){\n                if(matrix[i][j] < 0) {\n                    neg++;\n                }\n                ans += Math.abs(matrix[i][j]);\n                if(min > Math.abs(matrix[i][j]))\n                \tmin = Math.abs(matrix[i][j]);\n            }\n        }\n        if(neg % 2 == 0)\n        \treturn ans;\n        else{\n        \treturn ans - 2*min;\n        }\n    }\n}\n```
['Java']