🚨 C++ || 5 Lines || Faster 100%
Intuition\n- We traverse through the matrix and track three metrics\n\t- Sum of all the absolute value of elements\n\t- Min element\n\t- Is the count of negativ
**Intuition**\n- We traverse through the matrix and track three metrics\n\t- Sum of all the absolute value of elements\n\t- Min element\n\t- Is the count of negative element is odd\n- As adjacent pair can be multiplied by `-1` we can gather all negative elements in one place\n- And once we do that all pairs containing both negative value can be made positive\n- If there are odd number of negative value then we are left with one negative value (with minimum abs value)\n- As this element\'s abs value was already added in sum we deduct `2 * min_elem` when negative element count is odd\n\n**Code**\n```c++\nlong long maxMatrixSum(vector<vector<int>>& M) {\n    long long sum = 0, min_elem = INT_MAX; bool is_neg_count_odd = false;\n    for (auto r: M)\n        for (auto c: r)\n            is_neg_count_odd = c < 0 ? !is_neg_count_odd: is_neg_count_odd,\n            sum += abs(c),\n            min_elem = min(min_elem, (long long) abs(c));\n    return sum - (is_neg_count_odd ? 2 * min_elem: 0);\n}\n```\n\n**Complexity**\n`Time`: O(n * n)\n`Space`: O(1)\n\n**For more solutions and concepts, check out this \uD83D\uDCD6 [BLOG](https://github.com/MuhtasimTanmoy/notebook)  and  \uD83C\uDFC6 [GITHUB REPOSITORY](https://github.com/MuhtasimTanmoy/playground) with over 2000+ solutions.**\n\n![image](https://assets.leetcode.com/users/images/b1a085ce-d386-4858-adca-e2ecb51e97d6_1732436771.4125865.png)
['C']