Skip to content

Latest commit

 

History

History
28 lines (23 loc) · 785 Bytes

Row_with_max_1s.md

File metadata and controls

28 lines (23 loc) · 785 Bytes

Problem

class Solution {
    int rowWithMax1s(int arr[][], int n, int m) {
        // code here
        int leftMost_one_colIndex = m-1;
        int row=-1;
        
        for(int i=0;i<n;i++){
            if(arr[i][leftMost_one_colIndex]==0)
                continue;
            
            while(leftMost_one_colIndex>=0 && arr[i][leftMost_one_colIndex]!=0){
               leftMost_one_colIndex--; 
            }
            row=i;
            if(leftMost_one_colIndex<0)
                break;
        }
        
        return row;
    }
}

Editorial