LeetCode solutions

2737. Row With Maximum Ones

My accepted Python solution to LeetCode problem 2737, Row With Maximum Ones, running in 7ms.

  • Difficulty: Easy
  • Python
  • Runtime 7ms
  • Memory 18.1MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 7ms, memory 18.1MB, accepted 2025-12-31.

python
class Solution:
    def rowAndMaximumOnes(self, mat: List[List[int]]) -> List[int]:
        max_ones = 0
        max_row = 0
        for i, row in enumerate(mat):
            ones = sum(row)
            if ones > max_ones:
                max_ones = ones
                max_row = i
        return [max_row, max_ones]

Source