Skip to content

Commit 1de0d27

Browse files
committed
Create README - LeetHub
1 parent b25d816 commit 1de0d27

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
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-number-of-ones">1152. Maximum Number of Ones</a></h2><h3>Hard</h3><hr><p>Consider a matrix <code>M</code> with dimensions <code>width * height</code>, such that every cell has value <code>0</code>&nbsp;or <code>1</code>, and any <strong>square</strong>&nbsp;sub-matrix of <code>M</code> of size <code>sideLength * sideLength</code>&nbsp;has at most <code>maxOnes</code>&nbsp;ones.</p>
2+
3+
<p>Return the maximum possible number of ones that the matrix <code>M</code> can have.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
8+
<pre>
9+
<strong>Input:</strong> width = 3, height = 3, sideLength = 2, maxOnes = 1
10+
<strong>Output:</strong> 4
11+
<strong>Explanation:</strong>
12+
In a 3*3 matrix, no 2*2 sub-matrix can have more than 1 one.
13+
The best solution that has 4 ones is:
14+
[1,0,1]
15+
[0,0,0]
16+
[1,0,1]
17+
</pre>
18+
19+
<p><strong class="example">Example 2:</strong></p>
20+
21+
<pre>
22+
<strong>Input:</strong> width = 3, height = 3, sideLength = 2, maxOnes = 2
23+
<strong>Output:</strong> 6
24+
<strong>Explanation:</strong>
25+
[1,0,1]
26+
[1,0,1]
27+
[1,0,1]
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
<p><strong>Constraints:</strong></p>
32+
33+
<ul>
34+
<li><code>1 &lt;= width, height &lt;= 100</code></li>
35+
<li><code>1 &lt;= sideLength &lt;= width, height</code></li>
36+
<li><code>0 &lt;= maxOnes &lt;= sideLength * sideLength</code></li>
37+
</ul>

0 commit comments

Comments
 (0)