[JAVA] - Explanation | Simple, Easy and Concise Solution | Faster than 100% | 5ms
The main important point is that:\nIf the numbers with negative sign are even, than all can be converted to postitive numbers.\nIf the numbers with negative sig
The main important point is that:\nIf the numbers with negative sign are even, than all can be converted to postitive numbers.\nIf the numbers with negative sign are odd, than one will be left negative and others can be converted to positive.\nAlso, in case of odd no. of negative numbers, we can make all numbers positive and make smallest number negative, in order to maximise the sum.\n```\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```\nPlease upvote, if you Like and Understand the approach.
['Math', 'Java']