Skip to content

Practice Row With Maximum Ones

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2643
LeetCode Problem

Row With Maximum Ones

Problem Statement

Given a m x n binary matrix mat, find the 0-indexed position of the row that contains the maximum count of ones, and the number of ones in that row. In case there are multiple rows that have the maximum count of ones, the row with the smallest row number should be selected. Return an array containing the index of the row, and the number of ones in it.

Source: Row With Maximum Ones on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
mat = [[0,1],[1,0]]
Output
[0,1]

# Example 2

Input
mat = [[0,0,0],[0,1,1]]
Output
[1,2]

# Example 3

Input
mat = [[0,0],[1,1],[0,0]]
Output
[1,2]

Constraints

m == mat.length
n == mat[i].length
1 <= m, n <= 100
mat[i][j] is either 0 or 1.

Related LeetCode Problems

Practice more problems similar to Row With Maximum Ones.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.