Row with Max Ones

Problem Link: https://practice.geeksforgeeks.org/problems/maximum-no-of-1s-row3027/1

class Solution:
    def maxOnes (self, matrix, n, m):
        # code here 
        
        # Traversing starts from top-right
        i=0
        j=m-1
        ansrow=-1
        while(i<n and j>=0):
            if(matrix[i][j]==1):
                j-=1
                ansrow=i
            else:
                i+=1
        
        return ans

Last updated