C# | TC: O(M * N) | Easy Solution
Intuition\nThis initially seemed complex, but after reviewing the hint, I was able to figure it out. If the current matrix contains an even number of negative v
# Intuition\nThis initially seemed complex, but after reviewing the hint, I was able to figure it out. If the current matrix contains an even number of negative values, we can convert all of them to positive. However, if the number of negatives is odd, one negative value will remain. In this case, we identify the smallest absolute value in the matrix and subtract it from the total sum.\n\n# Approach\n- We will keep track of the total number of negative values in the matrix.\n- To calculate the total sum, we will use the absolute value of each cell.\n- If the count of negative numbers is even, we return the total sum directly Otherwise, we subtract the smallest absolute value twice from the total sum since it was initially added as a positive value.\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```csharp []\npublic class Solution {\n    public long MaxMatrixSum(int[][] matrix) {\n        //used for stroing total sum of the matrix\n        long totalSum = 0;\n        //this will store minimum abs values that we found in current matrix \n        var minNegative = int.MaxValue;\n        //will be using this variable to store total number of negative values in current matrix \n        var totalNegativeCount = 0;\n        //loop through each row\n        for (var i = 0; i < matrix.Length; i++)\n        {\n            //loop through each col \n            for (var j = 0; j < matrix[i].Length; j++)\n            {\n                //find min value in the current matrix so that if we have to subract we will do min value\n                minNegative = Math.Min(Math.Abs(matrix[i][j]), minNegative);\n                //if current one is < 0 then increment the count\n                if (matrix[i][j] < 0)\n                {\n                    totalNegativeCount++;\n                }\n                //add absolute value of current cell to the total sum \n                totalSum += Math.Abs(matrix[i][j]);\n            }\n        }\n        //if there are even negatives then we can convert them to postive else we will be endup with 1 negative value\n        //so remove it from the total, do 2 * because we added it to the total and then we have remove it from the total \n        //ex: [-1,2,3] ==> ABS total is 6 to make to get right sume we have to remove -1 twice  \n        return totalNegativeCount % 2 == 0 ? totalSum : totalSum - (2 * minNegative) ;\n    }\n}\n```
['C#']