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
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 7ms, memory 18.1MB, accepted 2025-12-31.
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]