[Beats 100%] Python one line optimal solution just for the kicks
Intuition\n Describe your first thoughts on how to solve this problem. \n1. The parity (even/odd) of number of negatives never changes.\n2. If the number of neg
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n1. The parity (even/odd) of number of negatives never changes.\n2. If the number of negatives is even, it can always be converted to all positives.\n3. If the number of negatives is odd, it can always be converted to just one negative, and rest all positives.\n    a. Any element can be selected to be the negative element.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. If even negatives, answer is the sum of the absolute values of all elements.\n2. If odd negatives, assume the smallest absolute value is negative. Therefore, take the sum of all elements, then subtract **2** times the minimum absolute value.\n\n# Complexity\n- Time complexity: $$O(n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n^2)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\n# Count negatives % 2\n# if 0, sum(abs(all))\n# if 1, sum(abs(all)) - minabs\n\n# total = sum(sum(map(abs, row)) for row in matrix)\n# if sum(sum(1 for num in row if num < 0) for row in matrix) % 2:\n#     total -= 2*min(min(map(abs, row)) for row in matrix)\n\n# return total\n\nclass Solution:\n    def maxMatrixSum(self, matrix: List[List[int]]) -> int:\n        return sum(sum(map(abs, row)) for row in matrix) - (2*min(min(map(abs, row)) for row in matrix) if (sum(sum(1 for num in row if num < 0) for row in matrix) % 2) else 0)\n\n\n```\n\nDo let me know if this can be shorter or more elegant :)
['Python3']