Skip to content

Commit be714aa

Browse files
committed
Added README.md file for Row With Maximum Ones
1 parent ac6f0b5 commit be714aa

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

2737-row-with-maximum-ones/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<h2><a href="https://leetcode.com/problems/row-with-maximum-ones">Row With Maximum Ones</a></h2> <img src='https://img.shields.io/badge/Difficulty-Easy-brightgreen' alt='Difficulty: Easy' /><hr><p>Given a <code>m x n</code> binary matrix <code>mat</code>, find the <strong>0-indexed</strong> position of the row that contains the <strong>maximum</strong> count of <strong>ones,</strong> and the number of ones in that row.</p>
2+
3+
<p>In case there are multiple rows that have the maximum count of ones, the row with the <strong>smallest row number</strong> should be selected.</p>
4+
5+
<p>Return<em> an array containing the index of the row, and the number of ones in it.</em></p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<pre>
11+
<strong>Input:</strong> mat = [[0,1],[1,0]]
12+
<strong>Output:</strong> [0,1]
13+
<strong>Explanation:</strong> Both rows have the same number of 1&#39;s. So we return the index of the smaller row, 0, and the maximum count of ones (1<code>)</code>. So, the answer is [0,1].
14+
</pre>
15+
16+
<p><strong class="example">Example 2:</strong></p>
17+
18+
<pre>
19+
<strong>Input:</strong> mat = [[0,0,0],[0,1,1]]
20+
<strong>Output:</strong> [1,2]
21+
<strong>Explanation:</strong> The row indexed 1 has the maximum count of ones <code>(2)</code>. So we return its index, <code>1</code>, and the count. So, the answer is [1,2].
22+
</pre>
23+
24+
<p><strong class="example">Example 3:</strong></p>
25+
26+
<pre>
27+
<strong>Input:</strong> mat = [[0,0],[1,1],[0,0]]
28+
<strong>Output:</strong> [1,2]
29+
<strong>Explanation:</strong> The row indexed 1 has the maximum count of ones (2). So the answer is [1,2].
30+
</pre>
31+
32+
<p>&nbsp;</p>
33+
<p><strong>Constraints:</strong></p>
34+
35+
<ul>
36+
<li><code>m == mat.length</code>&nbsp;</li>
37+
<li><code>n == mat[i].length</code>&nbsp;</li>
38+
<li><code>1 &lt;= m, n &lt;= 100</code>&nbsp;</li>
39+
<li><code>mat[i][j]</code> is either <code>0</code> or <code>1</code>.</li>
40+
</ul>

0 commit comments

Comments
 (0)