Search
⌘K

Leetcode 1975. Maximum Matrix Sum

Given an n×n integer matrix where you may multiply any two adjacent (edge-sharing) elements by -1 any number of times, maximize the matrix sum. Because adjacency flips affect opposite bipartition cells, the optimum is the sum of absolute values of all entries unless the count of negative numbers is odd (and there is no zero), in which case you must subtract twice the smallest absolute value.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.