Very simple visualization of problem, with Added YouTube explanation
Youtube Explanation https://youtu.be/wBngdBLYRmo?si=Z6B-PIzFD3820WiC\n\n# Intuition and approach\nthere could be below cases possible:- \n1) if all the numbers 
# Youtube Explanation https://youtu.be/wBngdBLYRmo?si=Z6B-PIzFD3820WiC\n\n# Intuition and approach\nthere could be below cases possible:- \n1) if all the numbers in matrix are positive ==> sum of all would be the answer.\n\n2) if there are negative numbers as well but they are in **even number of time** then also we can make them positibe using our **adjacent -1 multiply operation**.\n\n3) but in case of **negative numbers that too in odd frequency** we know that even after apply the -1 multiply operation, there would be always 1 number **left negative** , now we should try to make the negative number to the one that **have smallest absolute value** like in below matrix below has **3 negative numbers**\n\n10 40 **-5**           \n2  **-30** 20           \n4, **-10** 10         \n\nabove matrix can be easily brought to below matrix after doing our -1 muitiply operation, this will produce highest sum :- \n\n10 40 5\n**-2** 30 20\n4 10 10\n\nafter doing all -1 operation on adjacent numbers we can easily make our **mimnimum absolute value** (2) as left negative element so that we would still have higest sum.\n\nin single loop we can count the negative frequency and the sume of absolute values in the matrix and the smallest absolute value in matrix.\n\nnow if frequncy of nagative number is even ==> return **sum**.\nif its odd ==> return **sum - 2*minAbsolute value**\n\nwhy **2*minAbsolute value**?? ===> because when we were making sum we added everything as absolute values====> now as we now our absolute value would be left negative in case our frequency of **negative numbers is odd** ===> we have to deduct it two times.\n\n\n\n# Code\n```java []\nclass Solution {\n    public long maxMatrixSum(int[][] matrix) {\n    int min = Integer.MAX_VALUE;\n    long sum = 0;\n    int negCount = 0; \n    for(int i=0; i<matrix.length; i++)\n    for(int j=0; j<matrix[0].length; j++)\n    {\n     if(matrix[i][j]<0)\n     negCount++;\n     int ab = Math.abs(matrix[i][j]);\n     min = Math.min(min, ab);\n     sum += ab;    \n    }\n    if(negCount%2==0)\n    return sum; \n    return sum - 2*min;\n}\n}\n\n```\n```C# []\nclass Solution {\n    public long MaxMatrixSum(int[][] matrix) {\n    int min = int.MaxValue;\n    long sum = 0;\n    int negCount = 0; \n    for(int i=0; i<matrix.Length; i++)\n    for(int j=0; j<matrix[0].Length; j++)\n    {\n     if(matrix[i][j]<0)\n     negCount++;\n     int ab = Math.Abs(matrix[i][j]);\n     min = Math.Min(min, ab);\n     sum += ab;    \n    }\n    if(negCount%2==0)\n    return sum; \n    return sum - 2*min;\n}\n}\n```\n```C++ []\nclass Solution {\npublic:\n    long long maxMatrixSum(vector<vector<int>>& matrix) {\n        int minValue = INT_MAX;\n        long long sum = 0;\n        int negCount = 0;\n\n        for (int i = 0; i < matrix.size(); i++) {\n            for (int j = 0; j < matrix[0].size(); j++) {\n                if (matrix[i][j] < 0)\n                    negCount++;\n                int absValue = abs(matrix[i][j]);\n                minValue = min(minValue, absValue);\n                sum += absValue;\n            }\n        }\n\n        if (negCount % 2 == 0)\n            return sum;\n        return sum - 2 * minValue;\n    }\n};\n\n```\n```python []\nclass Solution(object):\n    def maxMatrixSum(self, matrix):\n        """\n        :type matrix: List[List[int]]\n        :rtype: int\n        """\n        min_value = float(\'inf\')  # Equivalent to Integer.MAX_VALUE\n        total_sum = 0\n        neg_count = 0\n\n        for row in matrix:\n            for value in row:\n                if value < 0:\n                    neg_count += 1\n                abs_value = abs(value)\n                min_value = min(min_value, abs_value)\n                total_sum += abs_value\n\n        if neg_count % 2 == 0:\n            return total_sum\n        return total_sum - 2 * min_value\n\n```\n\n\n\n\n\n
['Array', 'Math', 'Greedy', 'Matrix', 'Python', 'C++', 'Java', 'C#']