Tap here to switch tabs
Problem
Submissions

Problem: Maximum Matrix Sum

Try to solve the Maximum Matrix Sum problem.

Statement

Given an nimesnn imes n integer matrix, you are allowed to perform the following operation any number of times:

  • Select any two adjacent cells in matrix and multiply both values by −1-1.

Two cells are adjacent if they share a common edge horizontally or vertically.

Return the maximum possible sum of all elements in matrix after applying the operation any number of times.

Constraints:

  • n ==== matrix.length ==== matrix[i].length

  • 2≤2 \leq n ≤250\leq 250

  • −105≤-10^5 \leq matrix[i][j] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Matrix Sum

Try to solve the Maximum Matrix Sum problem.

Statement

Given an nimesnn imes n integer matrix, you are allowed to perform the following operation any number of times:

  • Select any two adjacent cells in matrix and multiply both values by −1-1.

Two cells are adjacent if they share a common edge horizontally or vertically.

Return the maximum possible sum of all elements in matrix after applying the operation any number of times.

Constraints:

  • n ==== matrix.length ==== matrix[i].length

  • 2≤2 \leq n ≤250\leq 250

  • −105≤-10^5 \leq matrix[i][j] ≤105\leq 10^5