Skip to content

Practice Maximum Matrix Sum

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1975
LeetCode Problem

Maximum Matrix Sum

Problem Statement

An operation negates both values of any two cells sharing an edge in matrix. Repeat any number of times and return the greatest achievable sum of all entries; diagonally touching cells are not adjacent.

Source: Maximum Matrix Sum on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
matrix = [[1,-1],[-1,1]]
Output
4

# Example 2

Input
matrix = [[1,2,3],[-1,-2,-3],[1,2,3]]
Output
16

Constraints

n == matrix.length == matrix[i].length
2 <= n <= 250
-10^5 <= matrix[i][j] <= 10^5

Related LeetCode Problems

Practice more problems similar to Maximum Matrix Sum.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.