Class Solution
java.lang.Object
g2601_2700.s2643_row_with_maximum_ones.Solution
2643 - Row With Maximum Ones.<p>Easy</p>
<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 **ones, ** and the number of ones in that row.</p>
<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>
<p>Return <em>an array containing the index of the row, and the number of ones in it.</em></p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> mat = [[0,1],[1,0]]</p>
<p><strong>Output:</strong> [0,1]</p>
<p><strong>Explanation:</strong> Both rows have the same number of 1’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].</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> mat = [[0,0,0],[0,1,1]]</p>
<p><strong>Output:</strong> [1,2]</p>
<p><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].</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> mat = [[0,0],[1,1],[0,0]]</p>
<p><strong>Output:</strong> [1,2]</p>
<p><strong>Explanation:</strong> The row indexed 1 has the maximum count of ones (2). So the answer is [1,2].</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>m == mat.length</code></li>
<li><code>n == mat[i].length</code></li>
<li><code>1 <= m, n <= 100</code></li>
<li><code>mat[i][j]</code> is either <code>0</code> or <code>1</code>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
rowAndMaximumOnes
public int[] rowAndMaximumOnes(int[][] mat)
-