https://leetcode.com/problems/row-with-maximum-ones/description/
Row With Maximum Ones - LeetCode
Can you solve this real interview question? Row With Maximum Ones - 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 ha
leetcode.com
1 2 3 4 5 6 7 8 9 10 11 | class Solution: def rowAndMaximumOnes(self, mat: List[List[int]]) -> List[int]: start_sum, idx = sum(mat[0]), 0 for i in range(1, len(mat)): if sum(mat[i]) > start_sum: idx = i start_sum = sum(mat[i]) answer = [idx, start_sum] return answer | cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2894. Divisible and Non-divisible Sums Difference (1) | 2024.01.05 |
---|---|
leetcode 2974. Minimum Number Game (0) | 2024.01.05 |
leetcode 2788. Split Strings by Separator (1) | 2024.01.02 |
leetcode 2824. Count Pairs Whose Sum is Less than Target (1) | 2024.01.02 |
leetcode 2729. Check if The Number is Fascinating (0) | 2023.12.29 |
댓글