Skip to content

Commit 18f7ff9

Browse files
committed
Create README - LeetHub
1 parent 54ca80d commit 18f7ff9

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

1975-maximum-matrix-sum/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<h2><a href="https://leetcode.com/problems/maximum-matrix-sum/">1975. Maximum Matrix Sum</a></h2><h3>Medium</h3><hr><div><p>You are given an <code>n x n</code> integer <code>matrix</code>. You can do the following operation <strong>any</strong> number of times:</p>
2+
3+
<ul>
4+
<li>Choose any two <strong>adjacent</strong> elements of <code>matrix</code> and <strong>multiply</strong> each of them by <code>-1</code>.</li>
5+
</ul>
6+
7+
<p>Two elements are considered <strong>adjacent</strong> if and only if they share a <strong>border</strong>.</p>
8+
9+
<p>Your goal is to <strong>maximize</strong> the summation of the matrix's elements. Return <em>the <strong>maximum</strong> sum of the matrix's elements using the operation mentioned above.</em></p>
10+
11+
<p>&nbsp;</p>
12+
<p><strong class="example">Example 1:</strong></p>
13+
<img alt="" src="https://assets.leetcode.com/uploads/2021/07/16/pc79-q2ex1.png" style="width: 401px; height: 81px;">
14+
<pre><strong>Input:</strong> matrix = [[1,-1],[-1,1]]
15+
<strong>Output:</strong> 4
16+
<b>Explanation:</b> We can follow the following steps to reach sum equals 4:
17+
- Multiply the 2 elements in the first row by -1.
18+
- Multiply the 2 elements in the first column by -1.
19+
</pre>
20+
21+
<p><strong class="example">Example 2:</strong></p>
22+
<img alt="" src="https://assets.leetcode.com/uploads/2021/07/16/pc79-q2ex2.png" style="width: 321px; height: 121px;">
23+
<pre><strong>Input:</strong> matrix = [[1,2,3],[-1,-2,-3],[1,2,3]]
24+
<strong>Output:</strong> 16
25+
<b>Explanation:</b> We can follow the following step to reach sum equals 16:
26+
- Multiply the 2 last elements in the second row by -1.
27+
</pre>
28+
29+
<p>&nbsp;</p>
30+
<p><strong>Constraints:</strong></p>
31+
32+
<ul>
33+
<li><code>n == matrix.length == matrix[i].length</code></li>
34+
<li><code>2 &lt;= n &lt;= 250</code></li>
35+
<li><code>-10<sup>5</sup> &lt;= matrix[i][j] &lt;= 10<sup>5</sup></code></li>
36+
</ul>
37+
</div>

0 commit comments

Comments
 (0)