Maximize the total sum of a matrix after repeatedly flipping the signs of entries subject to the problem’s operation rules.
You are given an matrix of integers. By applying the allowed operation any number of times, you may change the signs of values in the matrix according to the problem’s rules. Your goal is to make the final sum of all matrix entries as large as possible.
Think about what information actually matters after all operations are considered: the magnitudes of the values, how many negatives there are, and whether a zero can neutralize an unavoidable sign issue.
Example 1
Input
matrix = [[1,-1],[-1,1]]
Output
4
Explanation
All values can be made positive in the optimal configuration, so the maximum sum is 1 + 1 + 1 + 1 = 4.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.